Count macro
A macro to allow for compile time counting
How to use this
Every instance of _int_
will be replaced with either a literal or an ident.
count_macro::count
will panic in debug mode if counter exceeds usize.
If you wish to wrap to 0, please use count_macro::wrapping_count
.
Examples
Ident to literal
use count;
let a = count!;
assert_eq!;
Ident to ident
use count;
count!
assert_eq!;
assert_eq!;
In macro
use count;
my_macro!; // Will print from 0 to 3
Multiple counters
with _int_countername_
you'll be able to create a new counter called "countername".
This won't be incremented by _int_
or any other counter such as _int_0_
or _int_x_
.
use count;
// With two different counters
// _int_ does not increment _int_name_
count!
assert_eq!;
assert_eq!;
assert_eq!;