可以为导出的宏的单个匹配案例编写文档。
/// 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) => { ... };
}