gpt4 book ai didi

macros - 如何在宏中包含唯一匹配案例的文档?

转载 作者:行者123 更新时间:2023-11-29 08:27:15 29 4
gpt4 key购买 nike

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

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

最佳答案

你不能。唯一可以将文档附加到宏的地方是作为一个整体的宏。

关于macros - 如何在宏中包含唯一匹配案例的文档?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45244645/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com