为什么这样:
macro_rules! a_macro {
($($a:tt)+) => ($($a)+);
}
fn main() {
let x:u32 = 1;
let y:u32 = a_macro!(-x);
}
无法编译
<anon>:2:23: 2:25 error: unexpected token: `an interpolated tt`
<anon>:2 ($($a:tt)+) => ($($a)+);
^~
playpen: application terminated with error code 101
原因是:尚未实现。这是一个已知的限制(从Rust 1.0开始)。tt
宏的参数很有用,但使用时必须始终将其转发给宏。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句