Struct option_block::Block64
source · [−]pub struct Block64<T> { /* private fields */ }Expand description
A fixed block of optionals masked by a u64,
which may thus contain at most 64 elements.
Implementations
sourceimpl<T> Block64<T>
impl<T> Block64<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 get_or_else(&mut self, index: usize, func: impl FnOnce() -> T) -> &mut T
pub fn get_or_else(&mut self, index: usize, func: impl FnOnce() -> T) -> &mut T
If the slot at the given index is already occupied, this method returns a mutable
reference to the inner data. Otherwise, if the slot is vacant, then this method
inserts the value constructed by func. A mutable reference to the inner data is
also returned.
sourcepub fn get_or(&mut self, index: usize, val: T) -> &mut T
pub fn get_or(&mut self, index: usize, val: T) -> &mut T
Convenience wrapper for the get_or_else method.
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) -> Block64Iter<'_, T>ⓘNotable traits for Block64Iter<'a, T>impl<'a, T> Iterator for Block64Iter<'a, T> type Item = &'a T;
sourceimpl<T: Default> Block64<T>
impl<T: Default> Block64<T>
sourcepub fn get_or_default(&mut self, index: usize) -> &mut T
pub fn get_or_default(&mut self, index: usize) -> &mut T
Convenience wrapper for the get_or_else method.
Trait Implementations
sourceimpl<T: Clone> Clone for Block64<T>
impl<T: Clone> Clone for Block64<T>
Since the current implementation relies on MaybeUninit, the
block can only be cloned if the internal data is trivially copyable (bitwise).
It is necessary that the type does not implement Drop.
sourceimpl<T> Drop for Block64<T>
impl<T> Drop for Block64<T>
Ensure that all remaining items in the block are dropped. Since the implementation
internally uses MaybeUninit, we must manually drop the valid
(i.e. initialized) contents ourselves.
sourceimpl<T> FromIterator<(usize, T)> for Block64<T>
impl<T> FromIterator<(usize, T)> for Block64<T>
sourcefn from_iter<I>(iter: I) -> Self where
I: IntoIterator<Item = (usize, T)>,
fn from_iter<I>(iter: I) -> Self where
I: IntoIterator<Item = (usize, T)>,
Creates a value from an iterator. Read more
sourceimpl<T> IntoIterator for Block64<T>
impl<T> IntoIterator for Block64<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for Block64<T> where
T: RefUnwindSafe,
impl<T> Send for Block64<T> where
T: Send,
impl<T> Sync for Block64<T> where
T: Sync,
impl<T> Unpin for Block64<T> where
T: Unpin,
impl<T> UnwindSafe for Block64<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