You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#![feature(macro_metavar_expr)]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)});
println!("count(inner, 1): $inner repeats {} times in the inner repetitions", ${count(inner,1)});};}fnmain(){foo!{
outer ();
outer ( inner , inner );
outer ();
outer ( inner );};}
这时候的输出是:
count(outer, 0): $outer repeats 4 times
count(inner, 0): The $inner repetition repeats 3 times in the outer repetition
count(inner, 1): $inner repeats 3 times in the inner repetitions
而如果我把${count(inner)改为${count(inner, 0)后, 输出变成了:
count(outer, 0): $outer repeats 4 times
count(inner, 0): The $inner repetition repeats 4 times in the outer repetition
count(inner, 1): $inner repeats 3 times in the inner repetitions
我的版本是:
rustup 1.24.3 (ce5817a94 2021-05-31)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active rustc version is rustc 1.64.0-nightly (2f3ddd9f5 2022-06-27)
The text was updated successfully, but these errors were encountered:
在2.3.3章中,我使用count示例去测试: 如下是我的代码:
这时候的输出是:
count(outer, 0): $outer repeats 4 times
count(inner, 0): The $inner repetition repeats 3 times in the outer repetition
count(inner, 1): $inner repeats 3 times in the inner repetitions
而如果我把
${count(inner)
改为${count(inner, 0)
后, 输出变成了:count(outer, 0): $outer repeats 4 times
count(inner, 0): The $inner repetition repeats 4 times in the outer repetition
count(inner, 1): $inner repeats 3 times in the inner repetitions
我的版本是:
rustup 1.24.3 (ce5817a94 2021-05-31)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active
rustc
version isrustc 1.64.0-nightly (2f3ddd9f5 2022-06-27)
The text was updated successfully, but these errors were encountered: