Struct static_type_map::SendSyncStaticTypeMap
source · [−]pub struct SendSyncStaticTypeMap(_);
Expand description
Like StaticTypeMap
but with a Send
+ Sync
bound.
Implementations
sourceimpl SendSyncStaticTypeMap
impl SendSyncStaticTypeMap
sourcepub fn new() -> Self
pub fn new() -> Self
Creates an empty SendSyncStaticTypeMap
.
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 = SendSyncStaticTypeMap::new();
sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates an empty SendSyncStaticTypeMap
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 = SendSyncStaticTypeMap::with_capacity(10);
sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
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 = SendSyncStaticTypeMap::with_capacity(100);
assert!(type_map.capacity() >= 100);
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true
if the map contains no instances of any type.
Examples
let type_map = SendSyncStaticTypeMap::new();
assert!(type_map.is_empty());
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of types in the map.
Examples
let mut type_map = SendSyncStaticTypeMap::new();
assert_eq!(type_map.len(), 0);
type_map.insert("a");
assert_eq!(type_map.len(), 1);
sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clears the map. Keep allocated memory for reuse.
Examples
let mut type_map = SendSyncStaticTypeMap::new();
type_map.insert("a");
type_map.clear();
assert!(type_map.is_empty());
sourcepub fn reserve(&mut self, additional: usize)
pub fn reserve(&mut self, additional: usize)
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 = SendSyncStaticTypeMap::new();
assert_eq!(type_map.capacity(), 0);
type_map.reserve(10);
assert!(type_map.capacity() >= 10);
sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
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 = SendSyncStaticTypeMap::with_capacity(100);
assert!(type_map.capacity() >= 0);
type_map.insert("a");
type_map.insert(true);
assert!(type_map.capacity() >= 2);
sourcepub fn contains<T>(&self) -> bool where
T: Any,
pub fn contains<T>(&self) -> bool where
T: Any,
Returns true
if the map contains an instance of T
.
Examples
let mut type_map = SendSyncStaticTypeMap::new();
type_map.insert("a");
assert!(type_map.contains::<&str>());
Trait Implementations
sourceimpl Debug for SendSyncStaticTypeMap
impl Debug for SendSyncStaticTypeMap
sourceimpl Default for SendSyncStaticTypeMap
impl Default for SendSyncStaticTypeMap
sourcefn default() -> SendSyncStaticTypeMap
fn default() -> SendSyncStaticTypeMap
Returns the “default value” for a type. Read more
Auto Trait Implementations
impl !RefUnwindSafe for SendSyncStaticTypeMap
impl Send for SendSyncStaticTypeMap
impl Sync for SendSyncStaticTypeMap
impl Unpin for SendSyncStaticTypeMap
impl !UnwindSafe for SendSyncStaticTypeMap
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more