Skip to main content

DataArray

Trait DataArray 

Source
pub trait DataArray: DataCollection {
    // Required methods
    fn array_ref_get(
        &self,
        index: usize,
    ) -> Result<&<Self as DataCollection>::Element, IndexOutOfBounds> ;
    fn array_mut_get(
        &mut self,
        index: usize,
    ) -> Result<&mut <Self as DataCollection>::Element, IndexOutOfBounds> ;
    fn array_set(
        &mut self,
        index: usize,
        value: <Self as DataCollection>::Element,
    ) -> Result<(), IndexOutOfBounds> ;
    fn array_set_ref(
        &mut self,
        index: usize,
        value: &<Self as DataCollection>::Element,
    ) -> Result<(), IndexOutOfBounds> 
       where Self::Element: Clone;
}
Expand description

Required Methods§

Source

fn array_ref_get( &self, index: usize, ) -> Result<&<Self as DataCollection>::Element, IndexOutOfBounds>

Returns an immutable reference to the element at the specified index.

§Errors

Returns IndexOutOfBounds if the given index is out of bounds.

Source

fn array_mut_get( &mut self, index: usize, ) -> Result<&mut <Self as DataCollection>::Element, IndexOutOfBounds>

Returns a mutable reference to the element at the given index.

§Errors

Returns IndexOutOfBounds if the given index is out of bounds.

Source

fn array_set( &mut self, index: usize, value: <Self as DataCollection>::Element, ) -> Result<(), IndexOutOfBounds>

Sets the element at the specified index to the given value.

§Errors

Returns IndexOutOfBounds if the given index is out of bounds.

Source

fn array_set_ref( &mut self, index: usize, value: &<Self as DataCollection>::Element, ) -> Result<(), IndexOutOfBounds>
where Self::Element: Clone,

Sets the element at the specified index to the given clonable value.

§Errors

Returns IndexOutOfBounds if the given index is out of bounds.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T, const LEN: usize> DataArray for [T; LEN]

Source§

fn array_ref_get( &self, idx: usize, ) -> Result<&<Self as DataCollection>::Element, IndexOutOfBounds>

Source§

fn array_mut_get( &mut self, idx: usize, ) -> Result<&mut <Self as DataCollection>::Element, IndexOutOfBounds>

Source§

fn array_set( &mut self, idx: usize, value: <Self as DataCollection>::Element, ) -> Result<(), IndexOutOfBounds>

Source§

fn array_set_ref( &mut self, idx: usize, value: &<Self as DataCollection>::Element, ) -> Result<(), IndexOutOfBounds>
where T: Clone,

Implementors§

Source§

impl<T, const LEN: usize, S: Storage> DataArray for Array<T, LEN, S>

Source§

impl<T> DataArray for Vec<T>

Available on crate feature alloc only.