by codeflo · 4y ago · 0 comments
macro_rules! count {
() => (0);
($odd:tt ($a:tt $b:tt)*) => ((count!($($a)*) << 1) | 1);
(($a:tt $b:tt)*) => (count!($($a)*) << 1);
}
It uses bit twiddling to avoid generating very big AST and eventually crashing the compiler. Though I have to admit using `${count()}` is better.