Trait Array

Source
pub trait Array<T>: IndexMut<usize, Output = T> {
    // Required methods
    fn with_value(value: T, n: usize) -> Self
       where Self: Sized,
             T: Clone;
    fn len(&self) -> usize;
    unsafe fn get_unchecked(&self, index: usize) -> &T;
    unsafe fn get_unchecked_mut(&mut self, index: usize) -> &mut T;

    // Provided methods
    fn contains(&self, value: &T) -> bool
       where T: PartialEq { ... }
    fn is_empty(&self) -> bool { ... }
    fn get(&self, index: usize) -> Option<&T> { ... }
    fn get_mut(&mut self, index: usize) -> Option<&mut T> { ... }
    fn iter(&self) -> Iter<'_, T, Self> 
       where Self: Sized { ... }
}
Expand description

A simple trait for array like structs.

Required Methods§

Source

fn with_value(value: T, n: usize) -> Self
where Self: Sized, T: Clone,

Creates a new array with n repeated value.

Source

fn len(&self) -> usize

Returns the number of elements in the array.

Source

unsafe fn get_unchecked(&self, index: usize) -> &T

Returns a reference to the element of the array at index, without doing bounds checking.

Source

unsafe fn get_unchecked_mut(&mut self, index: usize) -> &mut T

Returns a mutable reference to the element of the array at index, without doing bounds checking.

Provided Methods§

Source

fn contains(&self, value: &T) -> bool
where T: PartialEq,

Returns true if the array contains value, false otherwise.

Source

fn is_empty(&self) -> bool

Returns true if the length of the array is 0, otherwise false.

Source

fn get(&self, index: usize) -> Option<&T>

Returns a reference to the element of the array at index, or None if the index is out of bounds.

Source

fn get_mut(&mut self, index: usize) -> Option<&mut T>

Returns a mutable reference to the element of the array at index, or None if the index is out of bounds.

Source

fn iter(&self) -> Iter<'_, T, Self>
where Self: Sized,

Returns a iterator over the array.

Implementors§

Source§

impl<T> Array<T> for VecArray<T>

Source§

impl<T, S, M, N> Array<T> for NestedArray<T, S, M, N>
where S: Split, M: Array<N>, N: Array<T> + Clone,

Source§

impl<T: Clone> Array<T> for RcArray<T>