Open chanced opened 1 year ago
~I don't think paste fits here, afaik the doc comment expects a &str
, and the result of paste is an identifier~.
I was wrong and it seems this is related to proc_macros expansion, and there is an unstable feature to expand macros that resolve to literals: https://github.com/rust-lang/rust/issues/90765
You can just use concat!
here, which does eager macro expansion:
macro_rules! create_string {
() => {
"example"
};
}
macro_rules! example {
() => {
#[doc = concat!(create_string!(), "a")]
fn example(){}
}
}
~You also would use [< >]
if you wanted to create a new identifier, but I'm not sure if paste can expand macros.~
I'm incredibly new to macros so I don't know if this is even possible to address.
If a macro that produces a string literal is used in
#[doc]
,paste
does not concat.