| Crates.io | inc-id |
| lib.rs | inc-id |
| version | 0.1.0 |
| created_at | 2025-12-27 16:14:52.58437+00 |
| updated_at | 2025-12-27 16:14:52.58437+00 |
| description | A no_std library for generating reusable auto-incrementing identifiers |
| homepage | |
| repository | |
| max_upload_size | |
| id | 2007455 |
| size | 32,348 |
A no_std library for generating reusable auto-incrementing identifiers (alloc is still required).
Incrementing values can make great unique identifiers because
This crate provides a generator that outputs serial values. Unsigned integers from the standard library
are supported by default, but any type can be supported simply by implementing the IncrementableId
trait.
For safety and stability, the generator prevents overflows by returning a Result, which will be an error
if the next generated value would exceed the maximum value for the type (e.g. u32::MAX).
If ids are never returned, ids will always be issued in increasing order. If you don't want ids to be reused, don't return them to the generator.
Warning: though there may be an observed pattern to how returned ids are reissued (increasing, decreasing, LIFO, FIFO, etc.) this is considered an implementation detail of the library and may change in future versions. For stability it is recommended to treat all generated ids as arbitrarily ordered if the return functionality is used.
no_stdserde feature flagUse a generator to create unique identifiers.
let mut id_gen = IdGenerator::<u32>::new();
assert_eq!(0, id_gen.get_id());
assert_eq!(1, id_gen.get_id());
This library is licensed under your choice of MIT or Apache 2.0