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

回答

2

你不能。您可以將文檔附加到宏的唯一位置是整個宏。