0

可以为导出的宏的单个匹配案例编写文档。

/// 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) => { ... };
}
4

1 回答 1

2

你不能。您可以将文档附加到宏的唯一位置是整个宏。

于 2017-07-22T03:58:55.590 回答