宏不扩展插值令牌树吗?

用户

为什么这样

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] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章