pub struct EnumVec<T: EnumArrayHelper<V>, V> { /* private fields */ }
Expand description
A vector of values V
indexed by enumoid T
.
Implementations§
Source§impl<T: EnumArrayHelper<V>, V> EnumVec<T, V>
impl<T: EnumArrayHelper<V>, V> EnumVec<T, V>
Sourcepub fn new_with<F>(size: EnumSize<T>, f: F) -> Selfwhere
F: FnMut(T) -> V,
pub fn new_with<F>(size: EnumSize<T>, f: F) -> Selfwhere
F: FnMut(T) -> V,
Creates a new vector with a specified number of elements generated by a callback function.
Sourcepub fn as_slice_mut(&mut self) -> &mut [V]
pub fn as_slice_mut(&mut self) -> &mut [V]
Returns a mutable slice containing all the values in the vector.
Sourcepub fn get_by_index(&self, index: EnumIndex<T>) -> Option<&V>
pub fn get_by_index(&self, index: EnumIndex<T>) -> Option<&V>
Returns a reference to the value associated with a given index,
or None
if the index is beyond the end of the vector.
Sourcepub fn get(&self, key: T) -> Option<&V>
pub fn get(&self, key: T) -> Option<&V>
Returns a reference to the value associated with a given key,
or None
if the key is beyond the end of the vector.
Sourcepub fn get_by_index_mut(&mut self, index: EnumIndex<T>) -> Option<&mut V>
pub fn get_by_index_mut(&mut self, index: EnumIndex<T>) -> Option<&mut V>
Returns a mutable reference to the value associated with a given index,
or None
if the index is beyond the end of the vector.
Sourcepub fn get_mut(&mut self, key: T) -> Option<&mut V>
pub fn get_mut(&mut self, key: T) -> Option<&mut V>
Returns a mutable reference to the value associated with a given key,
or None
if the key is beyond the end of the vector.
Sourcepub fn contains_index(&self, index: EnumIndex<T>) -> bool
pub fn contains_index(&self, index: EnumIndex<T>) -> bool
Returns true if the vector contains the index.
Sourcepub fn swap_remove(&mut self, key: T) -> Option<V>
pub fn swap_remove(&mut self, key: T) -> Option<V>
Removes an element and returns it, replacing it with the last element.