Trait kwap_common::Array [−][src]
pub trait Array: Default + Insert<Self::Item> + GetSize + Reserve + Deref<Target = [Self::Item]> + DerefMut + Extend<Self::Item> + FromIterator<Self::Item> + IntoIterator<Item = Self::Item> {
type Item;
}
Expand description
An ordered indexable collection of some type Item
Provided implementations
Notably, not heapless::ArrayVec
or arrayvec::ArrayVec
. An important usecase within kwap
is Extend
ing the collection, and the performance of heapless
and arrayvec
’s Extend implementations
are notably worse than tinyvec
.
tinyvec
also has the added bonus of being 100% unsafe-code-free, meaning if you choose tinyvec
you eliminate the
possibility of memory defects and UB.
Requirements
Default
for creating the collectionExtend
for mutating and adding onto the collection (1 or more elements)Reserve
for reserving space ahead of timeInsert
for pushing and inserting elements into the collectionGetSize
for bound checks, empty checks, and accessing the lengthFromIterator
forcollect
ing into the collectionIntoIterator
for iterating and destroying the collectionDeref<Target = [T]>
andDerefMut
for:- indexing (
Index
,IndexMut
) - iterating (
&[T].iter()
and&mut [T].iter_mut()
)
- indexing (