ArrayAllocPanic

Trait ArrayAllocPanic 

Source
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 use WillPanic anyway.

Required Methods§

Source

fn alloc_new() -> Self

Creates a newly allocated instance of Self

Source

fn alloc_clone<Source>(source: &Source) -> Self
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)

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)
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)

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

Source

fn push_front(&mut self, element: T)

Pushes an element to the front of self

Source

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

Pushes some elements to the front of self

Source

fn push_back(&mut self, element: T)

Pushes an element to the front of self

Source

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

Pushes some elements to the front of self

Source

fn pop_front(&mut self) -> Option<T>

Pops an element from the front of self

Source

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

Pops multiple elements from the front of self

Source

fn pop_back(&mut self) -> Option<T>

Pops an element from the back of self

Source

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.

Implementors§

Source§

impl<T, Array> ArrayAllocPanic<T> for Array
where Array: ArrayAlloc<T>,