如何在宏中包含唯一匹配案例的文档?
How to include documentation for unique match cases in macros?
是否可以为导出宏的各个匹配案例编写文档。
/// 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) => { ... };
}
你不能。唯一可以将文档附加到宏的地方是整个宏。
是否可以为导出宏的各个匹配案例编写文档。
/// 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) => { ... };
}
你不能。唯一可以将文档附加到宏的地方是整个宏。