I have found that sometimes it is very useful to know how many repetitions have been collected into a macro syntax variable. This is even something that has been asked about online. (See here as an example).
The method works, but smells of some of the problems of the C pre-processor and the sort of “hacks” that are required when working in that language.
Proposal:
Add a len() “method” on syntax variables for macro expansion.
Usage:
Example:
macro_rules! foo {
($($items),*) => (
$$len($items)
);
}
// in function
foo!("1", a, 8, true) // == 4usize
Alternatives:
Do nothing, the problem is actually currently solvable