It is small library for implementing autoincremental values, such as IDs or others.
toml
[dependencies]
autoincrement = "1"
```rust use autoincrement::prelude::*;
struct MyId(u32);
let mut generator = MyId::init();
asserteq!(generator.pull(), MyId(1)); asserteq!(generator.pull(), MyId(2)); assert_eq!(generator.pull(), MyId(3)); ```
```rust use autoincrement::prelude::*;
struct MyId(u32);
let mut generator = MyId(20).init_from();
asserteq!(generator.pull(), MyId(20)); asserteq!(generator.pull(), MyId(21)); assert_eq!(generator.pull(), MyId(22)); ```
toml
[dependencies]
autoincrement = { version = "1", features = ["derive", "async"] }
```rust use autoincrement::prelude::*;
struct MyId(u32);
let generator = MyId::init(); // does not need to be mutable
asserteq!(generator.pull(), MyId(1)); asserteq!(generator.pull(), MyId(2)); assert_eq!(generator.pull(), MyId(3)); ```