pub trait MaskTrackedArray<T>: Default {
type MaskType;
const MAX_COUNT: usize;
Show 17 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_empty_indices(&self) -> impl Iterator<Item = usize>;
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;
// 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> { ... }
}Expand description
Implemented by every variant of the mask tracked array. The
MaskTrackedArray::MaskType is the number type used for the mask with
MaskTrackedArray::MAX_COUNT being the size of the slots array.
Required Associated Constants§
Sourceconst MAX_COUNT: usize
const MAX_COUNT: usize
The maximum number of elements in the array. Note that this is based
on the number of bits in MaskTrackedArray::MaskType.
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_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.
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.