Crate utally

Source
Expand description

§UTally

This tool was created to allow easily creating unique ids for types in both static and dynamic contexts. The ids are sequential, this is basically a tally counter.

§Usage

Call next to acquire a new unique id.

let unique_id = utally::next();

§Using it in a static context

You can use LazyTally in order to assign ids to types or functions by using them in static contexts:

pub fn function_with_unique_id() -> usize {
    static SOME_TALLY: LazyTally = LazyTally::new();
    SOME_TALLY.get()
}

A call to function_with_unique_id would always return the same unique id.

Structs§

LazyTally
A lazy tally value. Each object of this type has an unique tally value that is assigned at the first call to LazyTally::get.
Tally
A tally counter

Statics§

GLOBAL_COUNTER
Global tally counter

Functions§

next
Acquires a new unique id. This adds 1 to the tally.
peek
Peeks to see which value would be returned in the next call for next. Because of concurrency, this does not mean you can call next after peek and get the same result in both. This function is designed to be used only in case you want to know where the tally is at, without increasing the values.