How do I create a Rust macro with optional parameters using repetitions?
问题 I'm currently looking into Rust macros and I can not find any detailed documentation on repetitions. I would like to create macros with optional parameters. This would be my idea: macro_rules! single_opt { ($mand_1, $mand_2, $($opt:expr)* ) =>{ match $opt { Some(x) => println!("1. {} 2. {}, 3. {}", $mand_1, $mand_2, x); None => single_opt!($mand_1, $mand_2, "Default"); } } } fn main() { single_opt!(4,4); } This example seems to be outdated, since I can not compile it. The Rust book mentions