Skip to main content

MutableArray

Trait MutableArray 

Source
pub trait MutableArray<T>: ImmutableArray<T> + AsMut<[T]> {
    // 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<(), ArrayTryCloneError>
       where T: TryClone;
    fn try_pop(&mut self) -> Result<T, ArrayIsEmptyError>;

    // 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: TryClone { ... }
    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>

Tries to push raw array to the array.

§Errors

For errors see ArrayError.

Source

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

Tries to push 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.

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: TryClone,

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".

Implementors§

Source§

impl<T, TAllocator> MutableArray<T> for DynamicArray<T, TAllocator>
where TAllocator: Allocator,

Source§

impl<T, TAllocator> MutableArray<T> for FixedArray<T, TAllocator>
where TAllocator: Allocator,

Source§

impl<const TCAPACITY: usize, T, TAllocator> MutableArray<T> for InlineDynamicArray<TCAPACITY, T, TAllocator>
where T: Sized, TAllocator: Allocator,

Source§

impl<const TSIZE: usize, T: Sized> MutableArray<T> for InlineFixedArray<TSIZE, T>