Trait ArrayCollection

Source
pub trait ArrayCollection<T>:
    Collection
    + Index<usize>
    + IndexMut<usize>
where T: PartialEq + Clone + Debug,
{ // Required methods fn get(&self, index: usize) -> Option<&T>; fn index_list(&self, item: &T) -> Option<Vec<usize>>; fn index_of(&self, item: &T) -> Option<usize>; fn last_index_of(&self, item: &T) -> Option<usize>; fn set(&mut self, index: usize, item: &T) -> Option<T>; fn slice(&mut self, r: Range<usize>) -> Box<[T]>; }

Required Methods§

Source

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

Returns the element at the specified index or None if the index is out-of-bounds.

Source

fn index_list(&self, item: &T) -> Option<Vec<usize>>

Returns a vector of indices that contain the specified element or None if the ‘array’ doesn’t contain the specified element.

Source

fn index_of(&self, item: &T) -> Option<usize>

Returns the first index of the specified element or None if the ‘array’ doesn’t contain the specified element.

Source

fn last_index_of(&self, item: &T) -> Option<usize>

Returns the last index of the specified element or None if the ‘array’ doesn’t contain the specified element.

Source

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

Sets the element at the specified index to the specified value. Returns the item being replaced at the specified index.

§Panics

This function panics if the specified index is out-of-bounds.

Source

fn slice(&mut self, r: Range<usize>) -> Box<[T]>

Returns a ‘slice’ of this ‘array’ within the specified index ‘range’.

§Panics

This function panics if the specified range is out-of-bounds.

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> ArrayCollection<T> for List<T>
where T: PartialEq + Clone + Debug,

Source§

impl<T> ArrayCollection<T> for Vector<T>
where T: PartialEq + Clone + Debug,

Source§

impl<T, const N: usize> ArrayCollection<T> for Array<T, N>
where T: PartialEq + Clone + Default + Copy + Debug,