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§
Required Methods§
Sourcefn alloc_clone<Source>(source: &Source) -> Result<Self, Self::Error>
fn alloc_clone<Source>(source: &Source) -> Result<Self, Self::Error>
Clones source
into a newly allocated instance of Self
Sourcefn grow_with(
&mut self,
len: usize,
init: impl FnMut() -> T,
) -> Result<(), Self::Error>
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
Sourcefn grow(&mut self, len: usize) -> Result<(), Self::Error>where
T: Default,
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
Sourcefn shrink(&mut self, len: usize) -> Result<(), Self::Error>
fn shrink(&mut self, len: usize) -> Result<(), Self::Error>
Shrinks self
to the given capacity if the current length is larger than len
Sourcefn push_front(&mut self, element: T) -> Result<(), Self::Error>
fn push_front(&mut self, element: T) -> Result<(), Self::Error>
Pushes an element
to the front of self
Sourcefn push_n_front<Source>(&mut self, elements: &Source) -> Result<(), Self::Error>
fn push_n_front<Source>(&mut self, elements: &Source) -> Result<(), Self::Error>
Pushes some elements
to the front of self
Sourcefn push_back(&mut self, element: T) -> Result<(), Self::Error>
fn push_back(&mut self, element: T) -> Result<(), Self::Error>
Pushes an element
to the front of self
Sourcefn push_n_back<Source>(&mut self, elements: &Source) -> Result<(), Self::Error>
fn push_n_back<Source>(&mut self, elements: &Source) -> Result<(), Self::Error>
Pushes some elements
to the front of self
Sourcefn pop_front(&mut self) -> Result<Option<T>, Self::Error>
fn pop_front(&mut self) -> Result<Option<T>, Self::Error>
Pops an element
from the front 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.