Crate ttmap

Source
Expand description

Trivial type-map implementation

Implementation uses type erased values with type as index.

§Hash implementation

The map uses simplified Hasher that relies on fact that Type::id is unique. In fact there is no hashing under hood, and type’s id is returned as it is.

§Usage

use ttmap::TypeMap;

let mut map = TypeMap::new();

map.insert("string");

assert_eq!(*map.get::<&'static str>().unwrap(), "string");

map.insert(1u8);

assert_eq!(*map.get::<u8>().unwrap(), 1);

assert_eq!(map.get_or_default::<String>(), "");

Structs§

RawType
Tag to indicate Raw boxed value
TypeMap
Type-safe store, indexed by types.
Value
Value type

Traits§

Type
Valid type allowed as key of type map

Type Aliases§

ValueBox
Boxed Type