MutableArray

Trait MutableArray 

Source
pub trait MutableArray<T>: ImmutableArray<T> + IndexMut<Length> {
    // Required methods
    fn try_push_array<const TSIZE: usize>(
        &mut self,
        arr: [T; TSIZE],
    ) -> Result<(), ArrayError>;
    fn try_push_slice(&mut self, slice: &[T]) -> Result<(), ArrayError>
       where T: Clone;
    fn try_pop(&mut self) -> Result<T, ArrayIsEmptyError>;
    fn as_slice_mut(&mut self) -> &mut [T];

    // Provided methods
    fn pop(&mut self) -> T { ... }
    fn try_push(&mut self, value: T) -> Result<(), ArrayError> { ... }
    fn push_array<const TSIZE: usize>(&mut self, arr: [T; TSIZE]) { ... }
    fn push_slice(&mut self, slice: &[T])
       where T: Clone { ... }
    fn push(&mut self, value: T) { ... }
}
Expand description

Represents a simply contiguous block of memory that is not only mutable internally but can also grow/shrink in size.

Required Methods§

Source

fn try_push_array<const TSIZE: usize>( &mut self, arr: [T; TSIZE], ) -> Result<(), ArrayError>

Pushes raw array to the array.

§Errors

For errors see ArrayError.

Source

fn try_push_slice(&mut self, slice: &[T]) -> Result<(), ArrayError>
where T: Clone,

Pushes slice to the array. This method requires Clone trait on T.

§Errors

For errors see ArrayError.

Source

fn try_pop(&mut self) -> Result<T, ArrayIsEmptyError>

Removes element from the top of the array.

§Errors

Returns ArrayIsEmptyError when the array is empty.

Source

fn as_slice_mut(&mut self) -> &mut [T]

Represents the array as mutable slice.

Provided Methods§

Source

fn pop(&mut self) -> T

Removes element from the top of the array.

§Panics

Panics if is the array is empty. Should be consistent with MutableArray::try_pop.

Source

fn try_push(&mut self, value: T) -> Result<(), ArrayError>

Pushes a single element to the array.

§Errors

For errors see ArrayError.

Source

fn push_array<const TSIZE: usize>(&mut self, arr: [T; TSIZE])

Pushes raw array to the array.

§Panics

Panics whenever MutableArray::try_push_array would.

Source

fn push_slice(&mut self, slice: &[T])
where T: Clone,

Pushes raw slice to the array. This method requires Clone trait on T.

§Panics

Panics whenever MutableArray::try_push_slice would.

Source

fn push(&mut self, value: T)

Pushes a single element to the array.

§Panics

Panics whenever MutableArray::try_push would.

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, TAllocator: Allocator> MutableArray<T> for DynamicArray<T, TAllocator>