pub trait MaskTrackedArray<T>:
Default
+ FromIterator<T>
+ FromIterator<(usize, T)> {
type MaskType: Mask;
Show 22 methods
// Required methods
fn contains_item_at(&self, index: usize) -> bool;
fn len(&self) -> u32;
fn clear(&mut self);
unsafe fn get_unchecked_ref(&self, index: usize) -> &T;
unsafe fn get_unchecked_mut(&self, index: usize) -> &mut T;
unsafe fn insert_unchecked(&self, index: usize, value: T);
unsafe fn remove_unchecked(&self, index: usize) -> T;
fn iter_filled_indices(&self) -> impl Iterator<Item = usize>;
fn iter_filled_indices_mask(
&self,
mask: Self::MaskType,
) -> impl Iterator<Item = usize>;
fn iter_empty_indices(&self) -> impl Iterator<Item = usize>;
fn mask(&self) -> Self::MaskType;
// Provided methods
fn is_empty(&self) -> bool { ... }
fn new() -> Self { ... }
fn get_ref(&self, index: usize) -> Option<&T> { ... }
fn get_mut(&mut self, index: usize) -> Option<&mut T> { ... }
fn insert(&self, index: usize, value: T) -> Option<T> { ... }
fn remove(&mut self, index: usize) -> Option<T> { ... }
fn iter<'a>(&'a self) -> impl Iterator<Item = &'a T>
where T: 'a { ... }
fn iter_mut<'a>(&'a mut self) -> impl Iterator<Item = &'a mut T>
where T: 'a { ... }
fn iter_mask<'a>(
&'a self,
mask: Self::MaskType,
) -> impl Iterator<Item = &'a T>
where T: 'a { ... }
fn iter_mut_mask<'a>(
&'a mut self,
mask: Self::MaskType,
) -> impl Iterator<Item = &'a mut T>
where T: 'a { ... }
fn push(&mut self, value: T) -> Result<usize, T> { ... }
}Expand description
Implemented by every variant of the mask tracked array. The
MaskTrackedArray::MaskType is the number type used for the mask.
Required Associated Types§
Required Methods§
Sourcefn contains_item_at(&self, index: usize) -> bool
fn contains_item_at(&self, index: usize) -> bool
Check if there is an item at a slot. This function will also return false if the index is out of range.
Sourcefn clear(&mut self)
fn clear(&mut self)
Clear out all items in this array, returning to its empty state. Drop is called if needed.
Sourceunsafe fn get_unchecked_ref(&self, index: usize) -> &T
unsafe fn get_unchecked_ref(&self, index: usize) -> &T
Get an immutable reference to slot without bounds or validity checking.
§Safety
The given index must be valid.
Sourceunsafe fn get_unchecked_mut(&self, index: usize) -> &mut T
unsafe fn get_unchecked_mut(&self, index: usize) -> &mut T
Get a mutable reference to a slot without bounds, validity or borrow checking.
§Safety
The given index must be valid and there must be no other references to the same slot.
Sourceunsafe fn insert_unchecked(&self, index: usize, value: T)
unsafe fn insert_unchecked(&self, index: usize, value: T)
Insert an item at a given index without bounds, validity or borrow checking.
§Safety
The given index must be valid to avoid undefined behaviour. If a value was already present, that value will be forgotten without running its drop implementation.
Sourceunsafe fn remove_unchecked(&self, index: usize) -> T
unsafe fn remove_unchecked(&self, index: usize) -> T
Remove a value from a slot without checking the index or if the item is there.
§Safety
Calling this function on currently referenced or nonexistent slots will result in undefined behaviour.
Sourcefn iter_filled_indices(&self) -> impl Iterator<Item = usize>
fn iter_filled_indices(&self) -> impl Iterator<Item = usize>
Get an iterator over all filled slot indices.
Sourcefn iter_filled_indices_mask(
&self,
mask: Self::MaskType,
) -> impl Iterator<Item = usize>
fn iter_filled_indices_mask( &self, mask: Self::MaskType, ) -> impl Iterator<Item = usize>
Get an iterator over all filled slot indices also present in the given mask.
Sourcefn iter_empty_indices(&self) -> impl Iterator<Item = usize>
fn iter_empty_indices(&self) -> impl Iterator<Item = usize>
Get an iterator over all unfilled slot indices.
Provided Methods§
Sourcefn get_ref(&self, index: usize) -> Option<&T>
fn get_ref(&self, index: usize) -> Option<&T>
Get a reference to an item inside a slot if available.
Sourcefn get_mut(&mut self, index: usize) -> Option<&mut T>
fn get_mut(&mut self, index: usize) -> Option<&mut T>
Get a mutable reference to an item inside a slot if available.
Sourcefn insert(&self, index: usize, value: T) -> Option<T>
fn insert(&self, index: usize, value: T) -> Option<T>
Try to insert an item at a given index. If insertion fails, return the value in an option. If the option is none then the insertion succeeded.
Sourcefn remove(&mut self, index: usize) -> Option<T>
fn remove(&mut self, index: usize) -> Option<T>
Remove a value at a specific index and return it if available.
Sourcefn iter<'a>(&'a self) -> impl Iterator<Item = &'a T>where
T: 'a,
fn iter<'a>(&'a self) -> impl Iterator<Item = &'a T>where
T: 'a,
Iterate over references to every filled slot.
Sourcefn iter_mut<'a>(&'a mut self) -> impl Iterator<Item = &'a mut T>where
T: 'a,
fn iter_mut<'a>(&'a mut self) -> impl Iterator<Item = &'a mut T>where
T: 'a,
Iterate over mutable references to every filled slot.
Sourcefn iter_mask<'a>(&'a self, mask: Self::MaskType) -> impl Iterator<Item = &'a T>where
T: 'a,
fn iter_mask<'a>(&'a self, mask: Self::MaskType) -> impl Iterator<Item = &'a T>where
T: 'a,
Iterate over references which are only present in the given mask.
Sourcefn iter_mut_mask<'a>(
&'a mut self,
mask: Self::MaskType,
) -> impl Iterator<Item = &'a mut T>where
T: 'a,
fn iter_mut_mask<'a>(
&'a mut self,
mask: Self::MaskType,
) -> impl Iterator<Item = &'a mut T>where
T: 'a,
Iterate over mutable references which are only present in the given mask.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.