forked from Veykril/tlborm
-
Notifications
You must be signed in to change notification settings - Fork 34
Closed
Description
我的rust版本是1.85.0-nightly
这是书中的写法:
macro_rules! foo {
( $( $outer:ident ( $( $inner:ident ),* ) ; )* ) => {
println!("count(outer, 0): $outer repeats {} times", ${count(outer)});
println!("count(inner, 0): The $inner repetition repeats {} times in the outer repetition", ${count(inner, 0)});
println!("count(inner, 1): $inner repeats {} times in the inner repetitions", ${count(inner, 1)});
};
}
这种写法会导致错误
在我添加$后写法正确,可能是因为后面版本语法改了?
修改后的写法:
macro_rules! foo {
( $( $outer:ident ( $( $inner:ident ),* ) ; )* ) => {
println!("count(outer, 0): $outer repeats {} times", ${count($outer)});
println!("count(inner, 0): The $inner repetition repeats {} times in the outer repetition", ${count($inner, 0)});
println!("count(inner, 1): $inner repeats {} times in the inner repetitions", ${count($inner, 1)});
};
}
Metadata
Metadata
Assignees
Labels
No labels