Trait toad_common::array::Array

source ·
pub trait Array: Default + GetSize + Reserve + Filled<Self::Item> + Trunc + Deref<Target = [Self::Item]> + DerefMut + Extend<Self::Item> + FromIterator<Self::Item> + IntoIterator<Item = Self::Item> {
    type Item;

    // Required methods
    fn insert_at(&mut self, index: usize, value: <Self as Array>::Item);
    fn remove(&mut self, index: usize) -> Option<<Self as Array>::Item>;
    fn push(&mut self, value: <Self as Array>::Item);
}
Expand description

An ordered indexable collection of some type Item

Provided implementations

Notably, not heapless::ArrayVec or arrayvec::ArrayVec. An important usecase within toad is Extending 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

Required Associated Types§

source

type Item

The type of item contained in the collection

Required Methods§

source

fn insert_at(&mut self, index: usize, value: <Self as Array>::Item)

Insert a value at a particular index of a collection.

source

fn remove(&mut self, index: usize) -> Option<<Self as Array>::Item>

Try to remove an entry from the collection.

Returns Some(Self::Item) if index was in-bounds, None if index is out of bounds.

source

fn push(&mut self, value: <Self as Array>::Item)

Add a value to the end of a collection.

Implementations on Foreign Types§

source§

impl<T> Array for Vec<T>

§

type Item = T

source§

fn insert_at(&mut self, index: usize, value: T)

source§

fn remove(&mut self, index: usize) -> Option<T>

source§

fn push(&mut self, value: T)

source§

impl<A: Array<Item = T>, T> Array for ArrayVec<A>where Self: Filled<T> + Trunc,

§

type Item = T

source§

fn insert_at(&mut self, index: usize, value: A::Item)

source§

fn remove(&mut self, index: usize) -> Option<T>

source§

fn push(&mut self, value: A::Item)

Implementors§