macro
Declarative macro arms and rule selection
A macro can recognize different input shapes. Put a more specific arm before a broader arm when the specific form needs distinct behavior. An expansion error does not make the compiler retry later arms. Expected stdout (not executed): 'Priority normal\n' Common mistake: Placing the general identifier arm first hides the urgent arm.
Formal Syntax & Structure
rust syntaxrust
(matcher) => { expansion }Working Example
Example Snippetrust
macro_rules! label { (urgent) => { "Priority" }; ($name:ident) => { stringify!($name) };}fn main() { println!("{} {}", label!(urgent), label!(normal)); }