id_cache
Download: crates.io/crates/id_cache
Docs: docs.rs/id_cache
This is a small crate built on id_collections
which provides a simple "cache" data structure for generating sequentially-assigned ids for unique values of some hashable type.
```rust use idcollections::idtype; use id_cache::IdCache;
struct WordId(u32);
let mut word_cache: IdCache
let fooid = wordcache.makeid("foo"); let barid = wordcache.makeid("bar");
asserteq!(wordcache[fooid], "foo"); asserteq!(wordcache[barid], "bar");
// ids for repeated values are reused: asserteq!(wordcache.makeid("foo"), fooid); ```
This crate has optional Serde support, which can be enabled with the serde
Cargo feature.