IndexMap

Struct IndexMap 

Source
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>

Source

pub const fn new() -> Self

Create a new IndexMap.

Returns a new IndexMap.

Source

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).

Source

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.

Source

pub fn raw_insert(&mut self, idx: usize, value: V) -> Result<(), Error>

Source

pub fn raw_remove(&mut self, idx: usize) -> Option<V>

Source

pub fn raw_at(&self, idx: usize) -> Option<&V>

Source

pub fn raw_at_mut(&mut self, idx: usize) -> Option<&mut V>

Trait Implementations§

Source§

impl<K: Debug + ?Sized + ToIndex, V: Debug, const N: usize> Debug for IndexMap<K, V, N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<K: ?Sized + ToIndex, V, const N: usize> Get<K> for IndexMap<K, V, N>

Source§

type Output = V

Source§

fn get<Q: Borrow<K>>(&self, index: Q) -> Option<&Self::Output>

Source§

impl<K: ?Sized + ToIndex, V, const N: usize> GetMut<K> for IndexMap<K, V, N>

Source§

fn get_mut<Q: Borrow<K>>(&mut self, index: Q) -> Option<&mut Self::Output>

Source§

fn get2_mut<Q: Borrow<K>>( &mut self, index1: Q, index2: Q, ) -> (Option<&mut Self::Output>, Option<&mut Self::Output>)

Source§

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>)

Source§

impl<K: Copy + ToIndex, V, const N: usize> Index<K> for IndexMap<K, V, N>

Source§

type Output = V

The returned type after indexing.
Source§

fn index(&self, index: K) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<K: Copy + ToIndex, V, const N: usize> IndexMut<K> for IndexMap<K, V, N>

Source§

fn index_mut(&mut self, index: K) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more

Auto Trait Implementations§

§

impl<K, V, const N: usize> Freeze for IndexMap<K, V, N>
where V: Freeze, K: ?Sized,

§

impl<K, V, const N: usize> RefUnwindSafe for IndexMap<K, V, N>

§

impl<K, V, const N: usize> Send for IndexMap<K, V, N>
where K: Send + ?Sized, V: Send,

§

impl<K, V, const N: usize> Sync for IndexMap<K, V, N>
where K: Sync + ?Sized, V: Sync,

§

impl<K, V, const N: usize> Unpin for IndexMap<K, V, N>
where K: Unpin + ?Sized, V: Unpin,

§

impl<K, V, const N: usize> UnwindSafe for IndexMap<K, V, N>
where K: UnwindSafe + ?Sized, V: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ThreadArgument for T
where T: Send + 'static,