pub struct IndexMap<K: ?Sized + ToIndex, V, const N: usize> {
data: [Option<V>; N],
phantom: PhantomData<K>,
}Expand description
This is a fixed-size map that can store up to N consecutive elements.
Fields§
§data: [Option<V>; N]§phantom: PhantomData<K>Implementations§
Source§impl<K: ?Sized + ToIndex, V, const N: usize> IndexMap<K, V, N>
impl<K: ?Sized + ToIndex, V, const N: usize> IndexMap<K, V, N>
Sourcepub fn insert(&mut self, idx: &K, value: V) -> Result<(), Error>
pub fn insert(&mut self, idx: &K, value: V) -> Result<(), Error>
Insert a value at the given index.
index - The index to insert the value at.
value - The value to insert.
Returns Ok(()) if the index was in-bounds, otherwise Err(KernelError::OutOfMemory).
Sourcepub fn remove(&mut self, idx: &K) -> Option<V>
pub fn remove(&mut self, idx: &K) -> Option<V>
Remove the value at the given index.
index - The index to remove the value from.
Returns the value if it was removed, otherwise None.
pub fn raw_insert(&mut self, idx: usize, value: V) -> Result<(), Error>
pub fn raw_remove(&mut self, idx: usize) -> Option<V>
pub fn raw_at(&self, idx: usize) -> Option<&V>
pub fn raw_at_mut(&mut self, idx: usize) -> Option<&mut V>
Trait Implementations§
Source§impl<K: ?Sized + ToIndex, V, const N: usize> GetMut<K> for IndexMap<K, V, N>
impl<K: ?Sized + ToIndex, V, const N: usize> GetMut<K> for IndexMap<K, V, N>
fn get_mut<Q: Borrow<K>>(&mut self, index: Q) -> Option<&mut Self::Output>
fn get2_mut<Q: Borrow<K>>( &mut self, index1: Q, index2: Q, ) -> (Option<&mut Self::Output>, Option<&mut Self::Output>)
fn get3_mut<Q: Borrow<K>>( &mut self, index1: Q, index2: Q, index3: Q, ) -> (Option<&mut Self::Output>, Option<&mut Self::Output>, Option<&mut Self::Output>)
Auto Trait Implementations§
impl<K, V, const N: usize> Freeze for IndexMap<K, V, N>
impl<K, V, const N: usize> RefUnwindSafe for IndexMap<K, V, N>
impl<K, V, const N: usize> Send for IndexMap<K, V, N>
impl<K, V, const N: usize> Sync for IndexMap<K, V, N>
impl<K, V, const N: usize> Unpin for IndexMap<K, V, N>
impl<K, V, const N: usize> UnwindSafe for IndexMap<K, V, N>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more