pub trait Array<T>: IndexMut<usize, Output = T> {
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;
fn contains(&self, value: &T) -> bool
where
T: PartialEq<T>,
{ ... }
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) -> Selfwhere
Self: Sized,
T: Clone,
fn with_value(value: T, n: usize) -> Selfwhere
Self: Sized,
T: Clone,
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<T>,
fn contains(&self, value: &T) -> boolwhere
T: PartialEq<T>,
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.