macro
Macro invocation delimiters
The exclamation mark signals a macro invocation. The outer delimiter of a matcher is flexible, but delimiters nested inside it carry meaning. Here the bracketed list is the actual input structure. Expected stdout (not executed): '(2, 8)\n' Common mistake: Removing the inner square brackets changes the matched structure.
Formal Syntax & Structure
rust syntaxrust
name!(...) / name![...] / name!{...}Working Example
Example Snippetrust
macro_rules! pair { ([$a:expr, $b:expr]) => { ($a, $b) }; }fn main() { println!("{:?}", pair!{[2, 8]}); }