When learning Rust, it's surprising to not find a namespace available within a package. Having crate features available at the top of the docs.rs package would be a great indication that some namespaces are gated behind features.
I think listing all the features of the crate is useful and in scope (maybe under the crate tab). However, we can't put it on the page for every module since those pages are generated by rustdoc.
Or in other words: just finding which features are available is simple, we just parse Cargo.toml; finding what changes when a given feature is enabled/disabled requires expanding macros and parsing the code and also lies on a weird boundary between cargo and rustdoc.
There's an extension that adds this already and I like their approach - they put an extra Features drop-down in the header at the top.
Relevant code:
Cargo.toml parsing - note that this is CargoMetadata, not Metadata. Metadata is only used for controlling the build parameters.One change I would suggest for the example drop-down would be to highlight the default feature, maybe by moving it to the top and adding a little whitespace/horizontal rule between it and the rest.
This was added in https://github.com/rust-lang/docs.rs/pull/1144.
Most helpful comment
There's an extension that adds this already and I like their approach - they put an extra
Featuresdrop-down in the header at the top.https://rust-search-extension.now.sh/feature-flags.png