macro

Resolve local matcher ambiguity

Give competing parts of a matcher distinct boundaries. The matcher cannot rely on arbitrary lookahead to choose where one repeated fragment ends and the next starts. Expected stdout (not executed): '("home", ["menu", "help"])\n' Common mistake: Using adjacent identifier repetition and a required identifier with no boundary.

Formal Syntax & Structure

rust syntaxrust
($name:ident ; $($tail:ident),*)

Working Example

Example Snippetrust
macro_rules! route { ($head:ident ; $($tail:ident),*) => { (stringify!($head), [$(stringify!($tail)),*]) }; }fn main() { println!("{:?}", route!(home; menu, help)); }
Rust Reference