A metavariable is a declarative-macro binding whose fragment specifier determines the syntactic category of captured Rust input. The dollar sign marks the binding; without it, the name is treated as a literal. section 2.1.4
Matching one expression
The matcher {$x:expr} captures one Rust expression as x. The expansion can then push $x into a newly created vector. section 2.1.4
Choose a fragment specifier that constrains the intended input:
- Use expr for expressions, ident for identifiers or keywords, block for blocks, and literal or type for those syntactic categories. section 2.1.4
- Use tt (TokenTree) when broader matching is necessary, but test carefully because it accepts almost anything and makes matchers less fine-grained. section 2.1.4
