Closed RealKC closed 2 years ago
Great! Can you add an example of such attribute for one of the fields in the rustdoc example of this macro? FYI all examples are tested to compile in the github workflows.
I updated the current example, is this good or should I go for something else?
I didn't understand you were referring to regular doc comments. It is not possible to put such comments without this PR? What about regular comments?
I didn't understand you were referring to regular doc comments. It is not possible to put such comments without this PR?
Yes, doc comments get desugared by the rust compiler into a #[doc]
attribute on the item, i.e.
struct Foo {
/// Doc comment
pub field: i32,
}
becomes
struct Foo {
#[doc = "Doc comment"]
pub field: i32,
}
It's also mentioned in the rust reference
What about regular comments?
I believe they don't get passed to macro_rules! macros (the page I linked above says they get interpreted as a form of whitespace)
OK, thanks for the explanations!
The main usecase this enables is putting doc comments on the fields as they get desugared to
#[doc="..."]
-style attributesI had a struct in my app that could use this macro but needed this feature, so I decided to add it myself