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§
Sourcefn with_value(value: T, n: usize) -> Self
fn with_value(value: T, n: usize) -> Self
Creates a new array with n repeated value.
Sourceunsafe fn get_unchecked(&self, index: usize) -> &T
unsafe fn get_unchecked(&self, index: usize) -> &T
Returns a reference to the element of the array at index, without doing bounds checking.
Sourceunsafe fn get_unchecked_mut(&mut self, index: usize) -> &mut T
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§
Sourcefn contains(&self, value: &T) -> boolwhere
T: PartialEq,
fn contains(&self, value: &T) -> boolwhere
T: PartialEq,
Returns true if the array contains value, false otherwise.
Sourcefn get(&self, index: usize) -> Option<&T>
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.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".