Crates.io | stacked_type_map |
lib.rs | stacked_type_map |
version | 0.1.0 |
source | src |
created_at | 2022-10-17 20:45:01.281243 |
updated_at | 2022-10-17 20:45:01.281243 |
description | Compile time map of any type. |
homepage | |
repository | https://github.com/Stock84-dev/stacked_type_map |
max_upload_size | |
id | 690388 |
size | 14,312 |
This map doesn't use any allocation or hashing.
use stacked_type_map::{StackedMap, Map, Removed};
let map = StackedMap;
assert_eq!(map.len(), 0);
let map = map.insert(1).insert(2).insert(3);
assert_eq!(map.get::<String>(), None);
assert_eq!(map.get::<i32>(), Some(&3));
assert_eq!(map.len(), 1);
let map2 = map.clone();
let map3 = map.clone();
assert!(matches!(map.remove::<String>(), Removed::NotFound(_)));
assert!(matches!(
map2.remove::<i32>(),
Removed::Removed { map: _, value: 3 }
));
let map = map3.insert(());
let map = map.insert("hi");
assert_eq!(
map.type_id_iter().collect::<Vec<_>>(),
vec![TypeId::of::<&'static str>(), TypeId::of::<()>()]
);