macro_rules! repeat {
($visibility:vis $name:ident { $to_repeat:ident; { $lower:expr , } } ) => { ... };
($visibility:vis $name:ident { $to_repeat:ident; { , $upper:expr } } ) => { ... };
($visibility:vis $name:ident { $to_repeat:ident; { , } } ) => { ... };
($visibility:vis $name:ident { $to_repeat:ident; { $amount:expr } } ) => { ... };
($visibility:vis $name:ident { $to_repeat:ident; { $lower:expr , $upper:expr } } ) => { ... };
}
Using a modified, regular-expression-like syntax, repeatedly calls another parser the number of times specified.
just!(pub a { "a"; } );
repeat!(pub repeat_a_five_times { a; { 5 } } );
repeat!(pub repeat_a_at_least_five_times { a; { 5, } } );
repeat!(pub repeat_a_forever { a; { , } } );