Here's an efficient counting macro I came up with while reading the chapter on Counting.
It can count a practically unlimited number of tokens with Rust's default recursion limit, it's faster than Slice length, and it produces a constant number.
I assert_eq'ed it on all numbers from 0 to 50, just to be on the safe side.
Here's an efficient counting macro I came up with while reading the chapter on Counting.
It can count a practically unlimited number of tokens with Rust's default recursion limit, it's faster than Slice length, and it produces a constant number.
I
assert_eq
'ed it on all numbers from 0 to 50, just to be on the safe side.Enjoy!