itemizer

Crates.ioitemizer
lib.rsitemizer
version1.0.3
created_at2025-03-11 10:15:30.735032+00
updated_at2025-04-02 15:04:21.196482+00
descriptionContaining an itemizer to itemize structs
homepage
repositoryhttps://github.com/nfbruns/itemizer
max_upload_size
id1587767
size13,513
Noah Bruns (nfbruns)

documentation

README

Itemizer

License

Itemizer is a data structure that maps items to unique integer IDs. It is used to convert items into unique IDs, and back again.

The Itemizer is generic over the type of the item, so it can be used with any type that implements the Eq, Hash, Ord, and Clone traits.

When calling id_of on an itemizer, it assigns an index, wrapped in an Item struct which represents this value. Using value_of, the original value can be retrieved.

Example


let mut itemizer = Itemizer::new();
let item1 = itemizer.id_of(&"item1".to_string());
let item2 = itemizer.id_of(&"item2".to_string());

assert_eq!(itemizer.value_of(&item1), &"item1".to_string());
assert_eq!(itemizer.value_of(&item2), &"item2".to_string());

Commit count: 9

cargo fmt