Trait ArrayLike

Source
pub trait ArrayLike<T, const N: usize>:
    From<[T; N]>
    + Into<[T; N]>
    + Index<usize, Output = T>
    + IndexMut<usize, Output = T> {
    type WithType<T2>: ArrayLike<T2, N>;

    const DIMENSION: usize = N;
Show 26 methods // Required methods fn array(&self) -> &[T; N]; fn array_mut(&mut self) -> &mut [T; N]; // Provided methods fn splat(value: T) -> Self where T: Clone { ... } fn map<U, F>(self, f: F) -> Self::WithType<U> where F: FnMut(T) -> U { ... } fn map_with<U, T2, F>( self, other: Self::WithType<T2>, f: F, ) -> Self::WithType<U> where F: FnMut(T, T2) -> U { ... } fn any<P>(&self, p: P) -> bool where P: FnMut(&T) -> bool { ... } fn any_with<T2, P>(&self, other: Self::WithType<T2>, p: P) -> bool where P: FnMut(&T, &T2) -> bool { ... } fn all<P>(&self, p: P) -> bool where P: FnMut(&T) -> bool { ... } fn all_with<T2, P>(&self, other: &Self::WithType<T2>, p: P) -> bool where P: FnMut(&T, &T2) -> bool { ... } fn for_each<F>(&self, f: F) where F: FnMut(&T) { ... } fn for_each_mut<F>(&mut self, f: F) where F: FnMut(&mut T) { ... } fn min_element(&self) -> &T where T: PartialOrd { ... } fn max_element(&self) -> &T where T: PartialOrd { ... } fn min_element_idx(&self) -> usize where T: PartialOrd { ... } fn max_element_idx(&self) -> usize where T: PartialOrd { ... } fn slice(&self) -> &[T] { ... } fn slice_mut(&mut self) -> &mut [T] { ... } fn have_idx(&self, idx: usize) -> bool { ... } fn get(&self, idx: usize) -> Option<&T> { ... } fn get_mut(&mut self, idx: usize) -> Option<&mut T> { ... } fn set_or_panic(&mut self, idx: usize, val: T) -> &mut Self { ... } fn set(&mut self, idx: usize, val: T) -> &mut Self { ... } fn try_set(&mut self, idx: usize, val: T) -> Result<(), T> { ... } fn with_or_panic(self, idx: usize, val: T) -> Self { ... } fn with(self, idx: usize, val: T) -> Self { ... } fn replace(&mut self, idx: usize, val: T) -> T { ... }
}

Provided Associated Constants§

Required Associated Types§

Source

type WithType<T2>: ArrayLike<T2, N>

Required Methods§

Source

fn array(&self) -> &[T; N]

Source

fn array_mut(&mut self) -> &mut [T; N]

Provided Methods§

Source

fn splat(value: T) -> Self
where T: Clone,

Source

fn map<U, F>(self, f: F) -> Self::WithType<U>
where F: FnMut(T) -> U,

Source

fn map_with<U, T2, F>( self, other: Self::WithType<T2>, f: F, ) -> Self::WithType<U>
where F: FnMut(T, T2) -> U,

Source

fn any<P>(&self, p: P) -> bool
where P: FnMut(&T) -> bool,

True if the predicate is true for at least one component

Source

fn any_with<T2, P>(&self, other: Self::WithType<T2>, p: P) -> bool
where P: FnMut(&T, &T2) -> bool,

True if the predicate is true for at least one component

Source

fn all<P>(&self, p: P) -> bool
where P: FnMut(&T) -> bool,

True if the predicate is true for all component

Source

fn all_with<T2, P>(&self, other: &Self::WithType<T2>, p: P) -> bool
where P: FnMut(&T, &T2) -> bool,

True if the predicate is true for all component

Source

fn for_each<F>(&self, f: F)
where F: FnMut(&T),

Source

fn for_each_mut<F>(&mut self, f: F)
where F: FnMut(&mut T),

Source

fn min_element(&self) -> &T
where T: PartialOrd,

Source

fn max_element(&self) -> &T
where T: PartialOrd,

Source

fn min_element_idx(&self) -> usize
where T: PartialOrd,

Source

fn max_element_idx(&self) -> usize
where T: PartialOrd,

Source

fn slice(&self) -> &[T]

Source

fn slice_mut(&mut self) -> &mut [T]

Source

fn have_idx(&self, idx: usize) -> bool

Source

fn get(&self, idx: usize) -> Option<&T>

Source

fn get_mut(&mut self, idx: usize) -> Option<&mut T>

Source

fn set_or_panic(&mut self, idx: usize, val: T) -> &mut Self

Panics if the component don’t exist

Source

fn set(&mut self, idx: usize, val: T) -> &mut Self

Do nothings if the component don’t exist

Source

fn try_set(&mut self, idx: usize, val: T) -> Result<(), T>

Source

fn with_or_panic(self, idx: usize, val: T) -> Self

Panics if the component don’t exist

Source

fn with(self, idx: usize, val: T) -> Self

Do nothings if the component don’t exist

Source

fn replace(&mut self, idx: usize, val: T) -> T

Replace the component and return the old component. Panic if the component don’t exist

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T, const N: usize> ArrayLike<T, N> for [T; N]

Source§

type WithType<T2> = [T2; N]

Source§

fn array(&self) -> &[T; N]

Source§

fn array_mut(&mut self) -> &mut [T; N]

Implementors§