是否可以为导出的宏的单个匹配案例编写文档。
/// This macro does stuff // this works
#[macro_export]
macro_rules! macro{
/// Today it's time for cats // error: no rules expected the token `[`
(cat) => { ... };
/// Today it's time for dogs // error: no rules expected the token `[`
(dog) => { ... };
/// Why not both // error: no rules expected the token `[`
(cats and dogs) => { ... };
}
这样的事情是可能的,还是我必须这样做:
/// This macro does stuff
/// `(cat)` - Today it's time for cats
/// `(dog)` - Today it's time for dogs
/// `(cats and dogs)` - Why not both
#[macro_export]
macro_rules! macro{
(cat) => { ... };
(dog) => { ... };
(cats and dogs) => { ... };
}
答案 0 :(得分:2)
你不能。您可以将文档附加到宏的唯一位置是整个宏。