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
🗃️ An abstract array data type.
Required Methods§
Sourcefn array_ref_get(
&self,
index: usize,
) -> Result<&<Self as DataCollection>::Element, IndexOutOfBounds> ⓘ
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.
Sourcefn array_mut_get(
&mut self,
index: usize,
) -> Result<&mut <Self as DataCollection>::Element, IndexOutOfBounds> ⓘ
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.
Sourcefn array_set(
&mut self,
index: usize,
value: <Self as DataCollection>::Element,
) -> Result<(), IndexOutOfBounds> ⓘ
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.
Sourcefn array_set_ref(
&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> ⓘ
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".