Trait checked_array::ArrayAlloc[][src]

pub trait ArrayAlloc<T>: ArrayMut<T> + Sized {
    type Error: Debug;
    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>; }

A trait for allocatable/resizeable linear array types

Associated Types

type Error: Debug[src]

An alloc related error

Loading content...

Required methods

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

Creates a newly allocated instance of Self

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

Clones source into a newly allocated instance of Self

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

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

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

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

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

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

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

Pushes an element to the front of self

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

Pushes some elements to the front of self

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

Pushes an element to the front of self

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

Pushes some elements to the front of self

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

Pops an element from the front of self

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

Pops multiple elements from the front of self

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

Pops an element from the back of self

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

Pops multiple elements from the back of self

Loading content...

Implementors

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

type Error = Wrapped::Error

Loading content...