pub trait ArrayAllocPanic<T>: ArrayMut<T> + Sized {
Show 13 methods
// Required methods
fn alloc_new() -> Self;
fn alloc_clone<Source>(source: &Source) -> Self
where Source: ArrayRef<T>,
T: Clone;
fn grow_with(&mut self, len: usize, init: impl FnMut() -> T);
fn grow(&mut self, len: usize)
where T: Default;
fn shrink(&mut self, len: usize);
fn push_front(&mut self, element: T);
fn push_n_front<Source>(&mut self, elements: &Source)
where Source: ArrayRef<T>,
T: Clone;
fn push_back(&mut self, element: T);
fn push_n_back<Source>(&mut self, elements: &Source)
where Source: ArrayRef<T>,
T: Clone;
fn pop_front(&mut self) -> Option<T>;
fn pop_n_front(&mut self, len: usize) -> Option<Self>;
fn pop_back(&mut self) -> Option<T>;
fn pop_n_back(&mut self, len: usize) -> Option<Self>;
}Expand description
An infallible/panicking variant of ArrayAlloc
- Note: This trait adopts Rust’s “panic on allocation failure” policy. While this trait reintroduces a panic cause,
it’s usually much more convenient to use – especially for
std-types which useWillPanicanyway.
Required Methods§
Sourcefn alloc_clone<Source>(source: &Source) -> Self
fn alloc_clone<Source>(source: &Source) -> Self
Clones source into a newly allocated instance of Self
Sourcefn grow_with(&mut self, len: usize, init: impl FnMut() -> T)
fn grow_with(&mut self, len: usize, init: impl FnMut() -> T)
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)where
T: Default,
fn grow(&mut self, len: usize)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)
fn shrink(&mut self, len: usize)
Shrinks self to the given capacity if the current length is larger than len
Sourcefn push_front(&mut self, element: T)
fn push_front(&mut self, element: T)
Pushes an element to the front of self
Sourcefn push_n_front<Source>(&mut self, elements: &Source)
fn push_n_front<Source>(&mut self, elements: &Source)
Pushes some elements to the front of self
Sourcefn push_n_back<Source>(&mut self, elements: &Source)
fn push_n_back<Source>(&mut self, elements: &Source)
Pushes some elements to the front of self
Sourcefn pop_n_front(&mut self, len: usize) -> Option<Self>
fn pop_n_front(&mut self, len: usize) -> Option<Self>
Pops multiple elements from the front of self
Sourcefn pop_n_back(&mut self, len: usize) -> Option<Self>
fn pop_n_back(&mut self, len: usize) -> Option<Self>
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.