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_core_array(&self) -> &[T; N];
fn as_mut_core_array(&mut self) -> &mut [T; N];
fn from_core_array(arr: [T; N]) -> Self;
fn ref_from_core_array(arr: &[T; N]) -> &Self;
fn ref_from_mut_core_array(arr: &mut [T; N]) -> &mut Self;
fn map_to_core_array<F, U>(self, f: F) -> [U; N]
where F: FnMut(T) -> U;
}
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_core_array(&self) -> &[T; N]
fn as_core_array(&self) -> &[T; N]
Returns a reference to the inner array.
sourcefn as_mut_core_array(&mut self) -> &mut [T; N]
fn as_mut_core_array(&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 ref_from_core_array(arr: &[T; N]) -> &Self
fn ref_from_core_array(arr: &[T; N]) -> &Self
Create array reference from reference to Rust’s core array type.
sourcefn ref_from_mut_core_array(arr: &mut [T; N]) -> &mut Self
fn ref_from_mut_core_array(arr: &mut [T; N]) -> &mut Self
Create mutable array reference from reference to Rust’s core array type.
sourcefn map_to_core_array<F, U>(self, f: F) -> [U; N]where
F: FnMut(T) -> U,
fn map_to_core_array<F, U>(self, f: F) -> [U; N]where
F: FnMut(T) -> U,
Returns an array of the same size as self
, with function f
applied to each element
in order.
Object Safety§
This trait is not object safe.