pub struct FlatVec<T, IndexTy: Default, BackingTy, const INDEX_INLINE_LEN: usize> { /* private fields */ }Expand description
An indirection-collapsing container with minimal allocation
Read as “An internally-flattening Vec of T, indexed by IndexTy, where each T is stored as a
slice of BackingTy”
For simple use cases, you may want a type alias for FlatVec<T, usize, u8, 3>, but under some
workloads it is very profitable to pick a smaller IndexTy, possibly even u8, and a
corresponding inline capacity.
Implementations§
Source§impl<'a, T: 'a, IndexTy, BackingTy, const INDEX_INLINE_LEN: usize> FlatVec<T, IndexTy, BackingTy, INDEX_INLINE_LEN>
impl<'a, T: 'a, IndexTy, BackingTy, const INDEX_INLINE_LEN: usize> FlatVec<T, IndexTy, BackingTy, INDEX_INLINE_LEN>
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new FlatVec, this is just an alias for the Default implementation.
Sourcepub fn data_len(&self) -> usize
pub fn data_len(&self) -> usize
Returns the number of BackingTy used to store the elements of a FlatVec. This does not
necessarily correlate with storage used to store the indices.
pub fn data_capacity(&self) -> usize
pub fn clear(&mut self)
Sourcepub fn push<Source>(&mut self, input: Source)where
Source: IntoFlat<BackingTy, T>,
pub fn push<Source>(&mut self, input: Source)where
Source: IntoFlat<BackingTy, T>,
Appends an element to the back of the collection.
Trait Implementations§
Source§impl<T: Clone, IndexTy: Clone + Default, BackingTy: Clone, const INDEX_INLINE_LEN: usize> Clone for FlatVec<T, IndexTy, BackingTy, INDEX_INLINE_LEN>
impl<T: Clone, IndexTy: Clone + Default, BackingTy: Clone, const INDEX_INLINE_LEN: usize> Clone for FlatVec<T, IndexTy, BackingTy, INDEX_INLINE_LEN>
Auto Trait Implementations§
impl<T, IndexTy, BackingTy, const INDEX_INLINE_LEN: usize> Freeze for FlatVec<T, IndexTy, BackingTy, INDEX_INLINE_LEN>where
IndexTy: Freeze,
impl<T, IndexTy, BackingTy, const INDEX_INLINE_LEN: usize> RefUnwindSafe for FlatVec<T, IndexTy, BackingTy, INDEX_INLINE_LEN>
impl<T, IndexTy, BackingTy, const INDEX_INLINE_LEN: usize> Send for FlatVec<T, IndexTy, BackingTy, INDEX_INLINE_LEN>
impl<T, IndexTy, BackingTy, const INDEX_INLINE_LEN: usize> Sync for FlatVec<T, IndexTy, BackingTy, INDEX_INLINE_LEN>
impl<T, IndexTy, BackingTy, const INDEX_INLINE_LEN: usize> Unpin for FlatVec<T, IndexTy, BackingTy, INDEX_INLINE_LEN>
impl<T, IndexTy, BackingTy, const INDEX_INLINE_LEN: usize> UnwindSafe for FlatVec<T, IndexTy, BackingTy, INDEX_INLINE_LEN>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more