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§
Sourcefn try_push_array<const TSIZE: usize>(
&mut self,
arr: [T; TSIZE],
) -> Result<(), ArrayError>
fn try_push_array<const TSIZE: usize>( &mut self, arr: [T; TSIZE], ) -> Result<(), ArrayError>
Sourcefn try_push_slice(&mut self, slice: &[T]) -> Result<(), ArrayError>where
T: Clone,
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
.
Sourcefn try_pop(&mut self) -> Result<T, ArrayIsEmptyError>
fn try_pop(&mut self) -> Result<T, ArrayIsEmptyError>
Removes element from the top of the array.
§Errors
Returns ArrayIsEmptyError
when the array is empty.
Sourcefn as_slice_mut(&mut self) -> &mut [T]
fn as_slice_mut(&mut self) -> &mut [T]
Represents the array as mutable slice.
Provided Methods§
Sourcefn pop(&mut self) -> T
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
.
Sourcefn try_push(&mut self, value: T) -> Result<(), ArrayError>
fn try_push(&mut self, value: T) -> Result<(), ArrayError>
Sourcefn push_array<const TSIZE: usize>(&mut self, arr: [T; TSIZE])
fn push_array<const TSIZE: usize>(&mut self, arr: [T; TSIZE])
Sourcefn push_slice(&mut self, slice: &[T])where
T: Clone,
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.
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.