| Crates.io | map_vec |
| lib.rs | map_vec |
| version | 0.6.0 |
| created_at | 2019-07-15 04:11:25.736244+00 |
| updated_at | 2024-09-07 21:15:20.652409+00 |
| description | The Map and Set APIs backed by Vec |
| homepage | |
| repository | https://github.com/nhynes/map_vec |
| max_upload_size | |
| id | 149102 |
| size | 88,075 |
map_vec::Map is a data structure with the interface of HashMap.
Similarly map_vec::Set is a data structure with the interface of HashSet.
Vector-backed maps and sets are primarily useful when you care about constant factors or prefer determinism to speed.
Please refer to the docs for HashMap and HashSet for details on and examples of using the Map/Set API.
Declare the map_vec dependency with serde support to get Serialize and Deserialize on Map and Set.
map_vec = { version = "0.6", features = ["serde"] }
let mut map = map_vec::Map::new();
map.insert("hello".to_string(), "world".to_string());
map.entry("hello".to_string()).and_modify(|mut v| v.push_str("!"));
assert_eq!(map.get("hello").map(String::as_str), Some("world!"))
let mut set1 = map_vec::Set::new();
let mut set2 = map_vec::Set::new();
set1.insert(1);
set1.insert(2);
set2.insert(2);
set2.insert(3);
let mut set3 = map_vec::Set::with_capacity(1);
assert!(set3.insert(3));
assert_eq!(&set2 - &set1, set3);