Safe, easy-to-use auto-increment integers
Auto-increment integers make great unique identifers because they do not need to
be large (i.e. using more memory) to prevent collisions. They are always unique
until they reach their max value, mimicking the behavior of PostgreSQL's
SERIAL
data type.
no_std
supportUse a generator to create unique identifiers.
```rust
use serial_int::SerialGenerator;
let mut gen = SerialGenerator::
asserteq!(0, gen.generate()); asserteq!(1, gen.generate()); ```
Using a wrapper to support concurrency or static ref
for generators that don't
have an owner is simple. See the docs for a more
complex example.
Submit a patch. If you add a new implementation of Serial, add a submodule to
tests
using the provided functions.