rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.65k stars 12.75k forks source link

rustdoc: highlight default enum variant #133174

Closed H2WO4 closed 1 hour ago

H2WO4 commented 2 hours ago

Problem

It would be convenient and help readability if enum variants marked with #[default] in the code would be also marked as such in the documentation.

While it is certainly possible to just use a doc comment, it would be better to have a standardized automatic solution.

Proposed Solution

Displaying (default) next to the default variant would be more than sufficient.

Quick mockup of what it could look like: Image

Additionally, pre- or postfixing the variant with a symbol could also be a viable solution.

Notes

A similar issue was already created in the docs.rs repository but closed as it should have been opened here.

This would only apply to variant using the #[default] attribute; manual Default impls would clearly be out of scope (due to the insanity of parsing the behavior of such a function).

weihanglo commented 1 hour ago

The rustdoc binary controls over how the HTML output looks like so this should be submitted to rust-lang/rust where rustdoc resides.

@rustbot transfer rust

fmease commented 1 hour ago

This feature request was FCP-closed in https://github.com/rust-lang/rust/pull/115575. Please see that PR and the linked issue for the rationale.