Trait ArrayAlloc

Source
pub trait ArrayAlloc<T>: ArrayMut<T> + Sized {
    type Error: Debug;

Show 13 methods // Required methods fn alloc_new() -> Result<Self, Self::Error>; fn alloc_clone<Source>(source: &Source) -> Result<Self, Self::Error> where Source: ArrayRef<T>, T: Clone; fn grow_with( &mut self, len: usize, init: impl FnMut() -> T, ) -> Result<(), Self::Error>; fn grow(&mut self, len: usize) -> Result<(), Self::Error> where T: Default; fn shrink(&mut self, len: usize) -> Result<(), Self::Error>; fn push_front(&mut self, element: T) -> Result<(), Self::Error>; fn push_n_front<Source>( &mut self, elements: &Source, ) -> Result<(), Self::Error> where Source: ArrayRef<T>, T: Clone; fn push_back(&mut self, element: T) -> Result<(), Self::Error>; fn push_n_back<Source>( &mut self, elements: &Source, ) -> Result<(), Self::Error> where Source: ArrayRef<T>, T: Clone; fn pop_front(&mut self) -> Result<Option<T>, Self::Error>; fn pop_n_front(&mut self, len: usize) -> Result<Option<Self>, Self::Error>; fn pop_back(&mut self) -> Result<Option<T>, Self::Error>; fn pop_n_back(&mut self, len: usize) -> Result<Option<Self>, Self::Error>;
}
Expand description

A trait for allocatable/resizeable linear array types

Required Associated Types§

Source

type Error: Debug

An alloc related error

Required Methods§

Source

fn alloc_new() -> Result<Self, Self::Error>

Creates a newly allocated instance of Self

Source

fn alloc_clone<Source>(source: &Source) -> Result<Self, Self::Error>
where Source: ArrayRef<T>, T: Clone,

Clones source into a newly allocated instance of Self

Source

fn grow_with( &mut self, len: usize, init: impl FnMut() -> T, ) -> Result<(), Self::Error>

Grows self to the given capacity if the current length is smaller than len and inits new elements using init

Source

fn grow(&mut self, len: usize) -> Result<(), Self::Error>
where T: Default,

Grows self to the given capacity if the current length is smaller than len and inits new elements using Default

Source

fn shrink(&mut self, len: usize) -> Result<(), Self::Error>

Shrinks self to the given capacity if the current length is larger than len

Source

fn push_front(&mut self, element: T) -> Result<(), Self::Error>

Pushes an element to the front of self

Source

fn push_n_front<Source>(&mut self, elements: &Source) -> Result<(), Self::Error>
where Source: ArrayRef<T>, T: Clone,

Pushes some elements to the front of self

Source

fn push_back(&mut self, element: T) -> Result<(), Self::Error>

Pushes an element to the front of self

Source

fn push_n_back<Source>(&mut self, elements: &Source) -> Result<(), Self::Error>
where Source: ArrayRef<T>, T: Clone,

Pushes some elements to the front of self

Source

fn pop_front(&mut self) -> Result<Option<T>, Self::Error>

Pops an element from the front of self

Source

fn pop_n_front(&mut self, len: usize) -> Result<Option<Self>, Self::Error>

Pops multiple elements from the front of self

Source

fn pop_back(&mut self) -> Result<Option<T>, Self::Error>

Pops an element from the back of self

Source

fn pop_n_back(&mut self, len: usize) -> Result<Option<Self>, Self::Error>

Pops multiple elements from the back of self

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.

Implementors§

Source§

impl<T, Wrapped> ArrayAlloc<T> for Array<Wrapped>
where Wrapped: AsRef<[T]> + AsMut<[T]> + CanAlloc<T>,

Source§

type Error = <Wrapped as CanAlloc<T>>::Error