Skip to content

rustdoc: How to render struct variants with no visible fields? #118195

Closed
@Kyuuhachi

Description

@Kyuuhachi

While working on #118192, I noticed that struct variants with no (visible) fields look kinda awkward.

pub enum MyEnum {
	/// A variant with no fields
	A {},
	/// A variant with hidden fields
	B { #[doc(hidden)] a: u8 },
}

rendering of the above code snippet

The Fields heading takes a lot of space without adding particularly much to the content. The easiest solution would be to just remove the heading, but that would show no indication that there exist private fields. The same issue exists in top-level structs as well, but there it is mitigated by having the definition in the code block just above, while for enums there can be a sizeable distance between the two.

Any thoughts? Am I just overthinking the whole thing?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-rustdoc-uiArea: Rustdoc UI (generated HTML)C-enhancementCategory: An issue proposing an enhancement or a PR with one.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions