Crate counting_macros

Source
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.