Struct option_block::Block8
source · [−]pub struct Block8<T> { /* private fields */ }Expand description
A fixed block of optionals masked by a u8,
which may thus contain at most 8 elements.
Implementations
sourceimpl<T> Block8<T>
impl<T> Block8<T>
sourcepub const fn is_vacant(&self, index: usize) -> bool
pub const fn is_vacant(&self, index: usize) -> bool
Checks whether the item at the index is vacant (i.e. contains None).
sourcepub fn get(&self, index: usize) -> Option<&T>
pub fn get(&self, index: usize) -> Option<&T>
Attempts to retrieve a shared reference to the element at index.
Returns None if the slot is vacant (i.e. uninitialized).
Panic
Panics if index >= CAPACITY. See the maximum capacity.
sourcepub fn get_mut(&mut self, index: usize) -> Option<&mut T>
pub fn get_mut(&mut self, index: usize) -> Option<&mut T>
Attempts to retrieve an exclusive reference to the element at
index. Returns None if the slot is vacant (i.e. uninitialized).
Panic
Panics if index >= CAPACITY. See the maximum capacity.
sourcepub fn insert(&mut self, index: usize, val: T) -> Option<T>
pub fn insert(&mut self, index: usize, val: T) -> Option<T>
Inserts the val at the index. If a value already exists, it returns Some
containing the old value. Otherwise, it returns None.
Panic
Panics if index >= CAPACITY. See the maximum capacity.
sourcepub fn remove(&mut self, index: usize) -> Option<T>
pub fn remove(&mut self, index: usize) -> Option<T>
Removes the value at the index. If a value already exists, it returns Some
containing that value. Otherwise, it returns None.
Panic
Panics if index >= CAPACITY. See the maximum capacity.
pub fn iter(&self) -> Block8Iter<'_, T>ⓘNotable traits for Block8Iter<'a, T>impl<'a, T> Iterator for Block8Iter<'a, T> type Item = &'a T;
Trait Implementations
sourceimpl<T: Copy> Clone for Block8<T>
impl<T: Copy> Clone for Block8<T>
Since the current implementation relies on MaybeUninit, the
block can only be cloned if the internal data is trivially copyable (bitwise).
sourceimpl<T> IntoIterator for Block8<T>
impl<T> IntoIterator for Block8<T>
sourceimpl<'a, T> IntoIterator for &'a Block8<T>
impl<'a, T> IntoIterator for &'a Block8<T>
impl<T: Copy> Copy for Block8<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for Block8<T> where
T: RefUnwindSafe,
impl<T> Send for Block8<T> where
T: Send,
impl<T> Sync for Block8<T> where
T: Sync,
impl<T> Unpin for Block8<T> where
T: Unpin,
impl<T> UnwindSafe for Block8<T> where
T: UnwindSafe,
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