pub struct StaticTypeMap(_);

Implementations

Creates an empty StaticTypeMap.

The map is initially created with a capacity of 0, so it will not allocate until it is first inserted into.

Examples
let type_map = StaticTypeMap::new();

Creates an empty StaticTypeMap with the specified capacity.

The map will be able to hold at least capacity types without reallocating. If capacity is 0, the static type map will not allocate.

Examples
let type_map = StaticTypeMap::with_capacity(10);

Returns the number of types the map can hold without reallocating.

This number is a lower bound; the map might be able to hold more, but it is guaranteed to be able to hold at least so many.

Examples
let type_map = StaticTypeMap::with_capacity(100);
assert!(type_map.capacity() >= 100);

Returns true if the map contains no instances of any type.

Examples
let type_map = StaticTypeMap::new();
assert!(type_map.is_empty());

Returns the number of types in the map.

Examples
let mut type_map = StaticTypeMap::new();
assert_eq!(type_map.len(), 0);
type_map.insert("a");
assert_eq!(type_map.len(), 1);

Clears the map. Keep allocated memory for reuse.

Examples
let mut type_map = StaticTypeMap::new();
type_map.insert("a");
type_map.clear();
assert!(type_map.is_empty());

Reserves capacity for at least additional more types to be inserted in the map. The collection may reserve more space to avoid frequent reallocations.

Panics

Panics if the new allocation size overflows usize.

Examples
let mut type_map = StaticTypeMap::new();
assert_eq!(type_map.capacity(), 0);
type_map.reserve(10);
assert!(type_map.capacity() >= 10);

Shrinks the capacity of the map as much as possible. It will drop down as much as possible while mainting the internal rules and possibly leaving some space in accordance with the resize policy.

Examples
let mut type_map = StaticTypeMap::with_capacity(100);
assert!(type_map.capacity() >= 0);
type_map.insert("a");
type_map.insert(true);
assert!(type_map.capacity() >= 2);

Returns true if the map contains an instance of T.

Examples
let mut type_map = StaticTypeMap::new();
type_map.insert("a");
assert!(type_map.contains::<&str>());

Returns a reference to an instance of T.

If the map does not have an instance of T, None is returned.

Examples
let mut type_map = StaticTypeMap::new();
type_map.insert("a");
assert_eq!(type_map.get::<&str>(), Some(&"a"));
assert_eq!(type_map.get::<bool>(), None);

Returns a mutable reference to an instance of T.

If the map does not have an instance of T, None is returned.

Examples
let mut type_map = StaticTypeMap::new();
type_map.insert("a");
if let Some(x) = type_map.get_mut::<&str>() {
    *x = "b";
}
assert_eq!(type_map.get::<&str>(), Some(&"b"));

Insert an instance of type T into the map.

If the map did not have this type present, None is returned.

Examples
let mut type_map = StaticTypeMap::new();
assert_eq!(type_map.insert("a"), None);
assert_eq!(type_map.insert("b"), Some("a"));

Remove and return an instance of type T from the map.

If the map did not have this type present, None is returned.

Examples
let mut type_map = StaticTypeMap::new();
type_map.insert("a");
assert_eq!(type_map.remove::<&str>(), Some("a"));

Trait Implementations

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.