Closed
Description
When writing associated constants in a struct's implementation, those constants appear under the Methods
section. Here's a minimal example:
struct Struc;
impl Struc {
const S: u64 = 0;
}
$ cargo doc
For traits though, they appear under Associated Constants
:
trait Tr {
const S: u64 = 0;
}
There should also be an Associated Constants
section for struct documentation.
Activity
MattX commentedon Apr 2, 2020
I've looked into this a little bit. It looks like for structs, rustdoc is grouping methods / associated types / associated constants / etc. per
impl
block. I agree this makes the "Methods" heading name a bit misleading. For instance,Will produce two subheadings under "Methods", both called "
impl Struc
", and each with its own constant documented.So if we want to keep doing it this way, we can't just add a toplevel "Associated constants headers". (As you mention, it does work for traits, since they don't have several sub-blocks in this way). We could do one of several things:
impl
headings to separate methods from other associated things. This might get a little crufty.impl
blocks that don't implement a trait (is there a name for these?) together in the doc, and place their combined elements under correct toplevel headings.Thoughts or other solutions?
melaquin commentedon Apr 2, 2020
I think renaming Methods to something else will be fine because it is a bit misleading. If I need to, I could put constants and methods in separate
impl
blocks or group relevant items together or something, and get to document eachimpl
block separatelyRollup merge of rust-lang#71918 - GuillaumeGomez:rename-methods-secti…