low-map 0.1.0

A convenient wrapper around a vector of options.
Documentation
  • Coverage
  • 70.37%
    19 out of 27 items documented1 out of 26 items with examples
  • Size
  • Source code size: 15.88 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 9.21 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • uben0/low-map
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • uben0

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