I am learning rust macros.
In the part on repetition, the following macro is used to demonstrate how repetitions work:
macro_rules! repeat_two { ($($i:ident)*, $($i2:ident)*) => { $( let $i: (); let $i2: (); )* } } repeat_two!( a b c d e f, u v w x y z ); Rust playground expands it to:
#![feature(prelude_import)] #[prelude_import] use std::prelude::rust_2024::*; #[macro_use] extern crate std; macro_rules! repeat_two { ($($i:ident)*, $($i2:ident)*) => { $(let $i: (); let $i2: ();)* } } fn main() { let a: (); let u: (); let b: (); let v: (); let c: (); let w: (); let d: (); let x: (); let e: (); let y: (); let f: (); let z: (); } I need help understanding how the $s are capturing the variables and/or expressions and how the separators are supplied.
How does it know that is the separator? Moreover, does the after the *, specify that there must be a after the , in the macro call?