fn count_repetitions<'a>(
dcx: DiagCtxtHandle<'a>,
depth_user: usize,
matched: &NamedMatch,
repeats: &[(usize, usize)],
sp: &DelimSpan,
) -> PResult<'a, usize>
Expand description
Used solely by the count
meta-variable expression, counts the outermost repetitions at a
given optional nested depth.
For example, a macro parameter of $( { $( $foo:ident ),* } )*
called with { a, b } { c }
:
[ $( ${count(foo)} ),* ]
will return [2, 1] with a, b = 2 and c = 1[ $( ${count(foo, 0)} ),* ]
will be the same as[ $( ${count(foo)} ),* ]
[ $( ${count(foo, 1)} ),* ]
will return an error because${count(foo, 1)}
is declared inside a single repetition and the index1
implies two nested repetitions.