宏不扩展插值标记树吗?
Do macros not expand interpolated token trees?
为什么 this:
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
宏 的参数,但在使用时必须始终将它们转发给宏。
为什么 this:
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
宏