macro
Zip parallel macro captures
When two captures drive a single repetition, their lengths must agree. The compiler does not truncate the longer list as an iterator zip might. Expected stdout (not executed): '[(1, 10), (2, 20)]\n' Common mistake: Passing unequal list lengths does not produce a shortened array.
Formal Syntax & Structure
rust syntaxrust
$( $a:expr ),* ; $( $b:expr ),*Working Example
Example Snippetrust
macro_rules! pairs { ($($a:expr),* ; $($b:expr),*) => { [$(($a, $b)),*] }; }fn main() { println!("{:?}", pairs!(1, 2; 10, 20)); }