Crates.io | low-map |
lib.rs | low-map |
version | 0.1.0 |
source | src |
created_at | 2021-06-12 19:07:40.220947 |
updated_at | 2021-06-12 19:07:40.220947 |
description | A convenient wrapper around a vector of options. |
homepage | |
repository | https://gitlab.com/uben0/low-map |
max_upload_size | |
id | 409390 |
size | 16,260 |
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"));