Skip to content

Commit

Permalink
fix: metavariable 出现变更
Browse files Browse the repository at this point in the history
  • Loading branch information
zjp-CN committed Dec 2, 2024
1 parent 9195678 commit 2508e7c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/decl-macros/minutiae/metavar-expr.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ bar!();
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)});
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)});
};
}
Expand Down Expand Up @@ -145,8 +145,8 @@ macro_rules! lets_count {
$(
println!(
"'{}' in inner iteration {}/{} with '{}' in outer iteration {}/{} ",
stringify!($inner), ${index()}, ${length()},
stringify!($outer), ${index(1)}, ${length(1)},
stringify!($inner), ${index()}, ${len()},
stringify!($outer), ${index(1)}, ${len(1)},
);
)*
)*
Expand Down Expand Up @@ -178,7 +178,7 @@ macro_rules! repetition_tuples {
(
${index()},
${index(1)}
${ignore(inner)} // without this metavariable expression, compilation would fail
${ignore($inner)} // without this metavariable expression, compilation would fail
),
)*
)*)
Expand Down

0 comments on commit 2508e7c

Please sign in to comment.