low-map

Crates.iolow-map
lib.rslow-map
version0.1.0
sourcesrc
created_at2021-06-12 19:07:40.220947
updated_at2021-06-12 19:07:40.220947
descriptionA convenient wrapper around a vector of options.
homepage
repositoryhttps://gitlab.com/uben0/low-map
max_upload_size
id409390
size16,260
uben (uben0)

documentation

https://docs.rs/low-map

README

LowMap

A convenient wrapper around a Vec<Option<T>>. It abstracts the optional presence of an element as being a non contiguous vector.

let mut map = LowMap::new();
map.insert(0, "hey");
map.insert(2, "hoy");
map.insert(3, "foo");
map.insert(2, "bar");

assert_eq!(map.get(0), Some(&"hey"));
assert_eq!(map.get(1), None);
assert_eq!(map.get(2), Some(&"bar"));
assert_eq!(map.get(3), Some(&"foo"));

map[2] = "hoho";
assert_eq!(map.get(2), Some(&"hoho"));
Commit count: 2

cargo fmt