Trait hybrid_array::ArrayOps
source · pub trait ArrayOps<T, const N: usize>: AsRef<[T; N]> + AsMut<[T; N]> + Borrow<[T; N]> + BorrowMut<[T; N]> + From<[T; N]> + Index<usize> + Index<Range<usize>> + IndexMut<usize> + IndexMut<Range<usize>> + IntoIterator + Sized {
type Size: ArraySize;
const SIZE: usize;
// Required methods
fn as_array_ref(&self) -> &[T; N];
fn as_array_mut(&mut self) -> &mut [T; N];
fn from_core_array(arr: [T; N]) -> Self;
fn from_slice(slice: &[T]) -> Result<Self, TryFromSliceError>
where T: Copy;
fn map<F, U>(self, f: F) -> [U; N]
where F: FnMut(T) -> U;
// Provided methods
fn from_fn<F>(cb: F) -> Self
where F: FnMut(usize) -> T { ... }
fn iter(&self) -> Iter<'_, T> { ... }
fn iter_mut(&mut self) -> IterMut<'_, T> { ... }
}
Expand description
Array operations which are const generic over a given array size.
Required Associated Types§
Required Associated Constants§
sourceconst SIZE: usize
const SIZE: usize
Size of an array as a usize
.
Not to be confused with ArrayOps::Size
, which is typenum
-based.
Required Methods§
sourcefn as_array_ref(&self) -> &[T; N]
fn as_array_ref(&self) -> &[T; N]
Returns a reference to the inner array.
sourcefn as_array_mut(&mut self) -> &mut [T; N]
fn as_array_mut(&mut self) -> &mut [T; N]
Returns a mutable reference to the inner array.
sourcefn from_core_array(arr: [T; N]) -> Self
fn from_core_array(arr: [T; N]) -> Self
Create array from Rust’s core array type.
sourcefn from_slice(slice: &[T]) -> Result<Self, TryFromSliceError>where
T: Copy,
fn from_slice(slice: &[T]) -> Result<Self, TryFromSliceError>where T: Copy,
Create array from a slice.