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

Create new counter.

Get counter value then increment it.

Increment counter.

See current count without incrementing it.

Change value of counter.