[英]How to test whether an identifier that is accessible only through a #define macro is defined?
[英]How do I test if a identifier in a macro starts with an underscore?
我需要檢查標識符是否以下划線開頭。 這不起作用:
#[macro_export]
macro_rules! UNDECORED {
(_$_i:ident) => {... do something if underscored};
($_i:ident) => {... do something else};
}
錯誤在哪里?
宏接收“令牌”作為輸入; 前導下划線不是單獨的標記,並且您不能匹配部分標記。
你可以stringify!
標識符,並在運行時匹配名稱。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.