stacked_type_map

Crates.iostacked_type_map
lib.rsstacked_type_map
version0.1.0
sourcesrc
created_at2022-10-17 20:45:01.281243
updated_at2022-10-17 20:45:01.281243
descriptionCompile time map of any type.
homepage
repositoryhttps://github.com/Stock84-dev/stacked_type_map
max_upload_size
id690388
size14,312
Stock84 (Stock84-dev)

documentation

README

stacked_type_map

version downloads docs licence

This map doesn't use any allocation or hashing.

Example

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::<()>()]
);
Commit count: 4

cargo fmt