Expand description
Stateful macro for compile time counting.
The counters use i32 for the backend. Only incrementing is supported.
counter_create!(count);
// Get the value of the counter & increment
assert_eq!(counter_incr!(count), 0);
// Get the value of the counter without incrementing
assert_eq!(counter_peek!(count), 1);
// Increment without getting value
counter_next!(count);
assert_eq!(counter_peek!(count), 2);
// Change the value of the counter
counter_set!(count, 12);
assert_eq!(counter_incr!(count), 12);
§Warning
I’m not certain about the stability or safety of this, so I would not recomend this for use in serious projects.
Macros§
- counter_
create - Create new counter.
- counter_
incr - Get counter value then increment it.
- counter_
next - Increment counter.
- counter_
peek - See current count without incrementing it.
- counter_
set - Change value of counter.