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.

Example

```rust use idcollections::idtype; use id_cache::IdCache;

[id_type]

struct WordId(u32);

let mut word_cache: IdCache = IdCache::new();

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); ```

Optional Features

This crate has optional Serde support, which can be enabled with the serde Cargo feature.