Crate static_type_map
source · [−]Expand description
This crate provides a StaticTypeMap
which allows you to store a single instance of any
'static
value as long as it implements Any
.
Examples
let mut type_map = StaticTypeMap::new();
type_map.insert(10u8);
type_map.insert(20u16);
type_map.insert(true);
type_map.insert("a");
assert!(type_map.contains::<bool>());
assert_eq!(type_map.get::<&str>(), Some(&"a"));
if let Some(previous_value) = type_map.insert(50u8) {
assert_eq!(previous_value, 10u8);
}
type_map.remove::<u16>();
assert_eq!(type_map.len(), 3);
Structs
Like StaticTypeMap
but with a Send
bound.
Like StaticTypeMap
but with a Send
+ Sync
bound.
A map where the key is the type of the value.