Trait array__ops::ArrayOps
source · pub trait ArrayOps<T, const N: usize>: Array + IntoIterator<Item = T> + Borrow<[T; N]> + BorrowMut<[T; N]> {
Show 147 methods
// Required methods
fn split_len(n: usize) -> (usize, usize);
fn rsplit_len(n: usize) -> (usize, usize);
fn split_ptr(&self, n: usize) -> (*const T, *const T);
fn split_mut_ptr(&mut self, n: usize) -> (*mut T, *mut T);
fn rsplit_ptr(&self, n: usize) -> (*const T, *const T);
fn rsplit_mut_ptr(&mut self, n: usize) -> (*mut T, *mut T);
fn fill<F>(fill: F) -> Self
where F: FnMut(usize) -> T;
fn rfill<F>(fill: F) -> Self
where F: FnMut(usize) -> T;
fn fill_boxed<F>(fill: F) -> Box<Self>
where F: FnMut(usize) -> T;
fn rfill_boxed<F>(fill: F) -> Box<Self>
where F: FnMut(usize) -> T;
fn fill_boxed_in<F, A>(fill: F, alloc: A) -> Box<Self, A>
where F: FnMut(usize) -> T,
A: Allocator;
fn rfill_boxed_in<F, A>(fill: F, alloc: A) -> Box<Self, A>
where F: FnMut(usize) -> T,
A: Allocator;
fn truncate<const M: usize>(self) -> [T; M]
where T:,
[(); { _ }]:;
fn rtruncate<const M: usize>(self) -> [T; M]
where T:,
[(); { _ }]:;
fn truncate_ref<const M: usize>(&self) -> &[T; M]
where [(); { _ }]:;
fn rtruncate_ref<const M: usize>(&self) -> &[T; M]
where [(); { _ }]:;
fn truncate_mut<const M: usize>(&mut self) -> &mut [T; M]
where [(); { _ }]:;
fn rtruncate_mut<const M: usize>(&mut self) -> &mut [T; M]
where [(); { _ }]:;
fn resize<const M: usize, F>(self, fill: F) -> [T; M]
where F: FnMut(usize) -> T,
T:;
fn rresize<const M: usize, F>(self, fill: F) -> [T; M]
where F: FnMut(usize) -> T,
T:;
fn extend<const M: usize, F>(self, fill: F) -> [T; M]
where F: FnMut(usize) -> T,
[(); { _ }]:;
fn rextend<const M: usize, F>(self, fill: F) -> [T; M]
where F: FnMut(usize) -> T,
[(); { _ }]:;
fn reformulate_length<const M: usize>(self) -> [T; M]
where [(); { _ }]:;
fn reformulate_length_ref<const M: usize>(&self) -> &[T; M]
where [(); { _ }]:;
fn reformulate_length_mut<const M: usize>(&mut self) -> &mut [T; M]
where [(); { _ }]:;
fn try_reformulate_length<const M: usize>(self) -> Result<[T; M], Self>;
fn try_reformulate_length_ref<const M: usize>(&self) -> Option<&[T; M]>;
fn try_reformulate_length_mut<const M: usize>(
&mut self
) -> Option<&mut [T; M]>;
fn into_collumn(self) -> [[T; 1]; N];
fn as_collumn(&self) -> &[[T; 1]; N];
fn as_collumn_mut(&mut self) -> &mut [[T; 1]; N];
fn map2<Map>(self, map: Map) -> [Map::Output; N]
where Map: FnMut<(T,)>;
fn map_outer<Map>(&self, map: Map) -> [[Map::Output; N]; N]
where Map: FnMut<(T, T)>,
T: Copy;
fn comap<Map, Rhs>(self, rhs: [Rhs; N], map: Map) -> [Map::Output; N]
where Map: FnMut<(T, Rhs)>;
fn comap_outer<Map, Rhs, const M: usize>(
&self,
rhs: &[Rhs; M],
map: Map
) -> [[Map::Output; M]; N]
where Map: FnMut<(T, Rhs)>,
T: Copy,
Rhs: Copy;
fn flat_map<Map, O, const M: usize>(self, map: Map) -> [O; { _ }]
where Map: FnMut<(T,), Output = [O; M]>;
fn map_assign<Map>(&mut self, map: Map)
where Map: FnMut(T) -> T;
fn zip<Z>(self, other: [Z; N]) -> [(T, Z); N];
fn zip_outer<Z, const M: usize>(&self, other: &[Z; M]) -> [[(T, Z); M]; N]
where T: Copy,
Z: Copy;
fn enumerate(self) -> [(usize, T); N];
fn diagonal<const H: usize, const W: usize>(self) -> [[T; W]; H]
where T: Default + Copy,
[(); { _ }]:;
fn differentiate(&mut self)
where T: SubAssign<T> + Copy;
fn integrate(&mut self)
where T: AddAssign<T> + Copy;
fn reduce<R>(self, reduce: R) -> Option<T>
where R: FnMut(T, T) -> T;
fn try_sum(self) -> Option<T>
where T: AddAssign;
fn sum_from<S>(self, from: S) -> S
where S: AddAssign<T>;
fn try_product(self) -> Option<T>
where T: MulAssign;
fn product_from<P>(self, from: P) -> P
where P: MulAssign<T>;
fn max(self) -> Option<T>
where T: Ord;
fn min(self) -> Option<T>
where T: Ord;
fn first_max(self) -> Option<T>
where T: PartialOrd<T>;
fn first_min(self) -> Option<T>
where T: PartialOrd<T>;
fn argmax(&self) -> Option<usize>
where T: PartialOrd<T>;
fn argmin(&self) -> Option<usize>
where T: PartialOrd<T>;
fn add_all<Rhs>(self, rhs: Rhs) -> [<T as Add<Rhs>>::Output; N]
where T: Add<Rhs>,
Rhs: Copy;
fn sub_all<Rhs>(self, rhs: Rhs) -> [<T as Sub<Rhs>>::Output; N]
where T: Sub<Rhs>,
Rhs: Copy;
fn mul_all<Rhs>(self, rhs: Rhs) -> [<T as Mul<Rhs>>::Output; N]
where T: Mul<Rhs>,
Rhs: Copy;
fn div_all<Rhs>(self, rhs: Rhs) -> [<T as Div<Rhs>>::Output; N]
where T: Div<Rhs>,
Rhs: Copy;
fn rem_all<Rhs>(self, rhs: Rhs) -> [<T as Rem<Rhs>>::Output; N]
where T: Rem<Rhs>,
Rhs: Copy;
fn shl_all<Rhs>(self, rhs: Rhs) -> [<T as Shl<Rhs>>::Output; N]
where T: Shl<Rhs>,
Rhs: Copy;
fn shr_all<Rhs>(self, rhs: Rhs) -> [<T as Shr<Rhs>>::Output; N]
where T: Shr<Rhs>,
Rhs: Copy;
fn bitor_all<Rhs>(self, rhs: Rhs) -> [<T as BitOr<Rhs>>::Output; N]
where T: BitOr<Rhs>,
Rhs: Copy;
fn bitand_all<Rhs>(self, rhs: Rhs) -> [<T as BitAnd<Rhs>>::Output; N]
where T: BitAnd<Rhs>,
Rhs: Copy;
fn bitxor_all<Rhs>(self, rhs: Rhs) -> [<T as BitXor<Rhs>>::Output; N]
where T: BitXor<Rhs>,
Rhs: Copy;
fn add_assign_all<Rhs>(&mut self, rhs: Rhs)
where T: AddAssign<Rhs>,
Rhs: Copy;
fn sub_assign_all<Rhs>(&mut self, rhs: Rhs)
where T: SubAssign<Rhs>,
Rhs: Copy;
fn mul_assign_all<Rhs>(&mut self, rhs: Rhs)
where T: MulAssign<Rhs>,
Rhs: Copy;
fn div_assign_all<Rhs>(&mut self, rhs: Rhs)
where T: DivAssign<Rhs>,
Rhs: Copy;
fn rem_assign_all<Rhs>(&mut self, rhs: Rhs)
where T: RemAssign<Rhs>,
Rhs: Copy;
fn shl_assign_all<Rhs>(&mut self, rhs: Rhs)
where T: ShlAssign<Rhs>,
Rhs: Copy;
fn shr_assign_all<Rhs>(&mut self, rhs: Rhs)
where T: ShrAssign<Rhs>,
Rhs: Copy;
fn bitor_assign_all<Rhs>(&mut self, rhs: Rhs)
where T: BitOrAssign<Rhs>,
Rhs: Copy;
fn bitand_assign_all<Rhs>(&mut self, rhs: Rhs)
where T: BitAndAssign<Rhs>,
Rhs: Copy;
fn bitxor_assign_all<Rhs>(&mut self, rhs: Rhs)
where T: BitXorAssign<Rhs>,
Rhs: Copy;
fn add_all_neg<Rhs>(self, rhs: Rhs) -> [<Rhs as Sub<T>>::Output; N]
where Rhs: Copy + Sub<T>;
fn mul_all_inv<Rhs>(self, rhs: Rhs) -> [<Rhs as Div<T>>::Output; N]
where Rhs: Copy + Div<T>;
fn neg_all(self) -> [<T as Neg>::Output; N]
where T: Neg;
fn neg_assign_all(&mut self)
where T: Neg<Output = T>;
fn add_each<Rhs>(self, rhs: [Rhs; N]) -> [<T as Add<Rhs>>::Output; N]
where T: Add<Rhs>;
fn sub_each<Rhs>(self, rhs: [Rhs; N]) -> [<T as Sub<Rhs>>::Output; N]
where T: Sub<Rhs>;
fn mul_each<Rhs>(self, rhs: [Rhs; N]) -> [<T as Mul<Rhs>>::Output; N]
where T: Mul<Rhs>;
fn div_each<Rhs>(self, rhs: [Rhs; N]) -> [<T as Div<Rhs>>::Output; N]
where T: Div<Rhs>;
fn rem_each<Rhs>(self, rhs: [Rhs; N]) -> [<T as Rem<Rhs>>::Output; N]
where T: Rem<Rhs>;
fn shl_each<Rhs>(self, rhs: [Rhs; N]) -> [<T as Shl<Rhs>>::Output; N]
where T: Shl<Rhs>;
fn shr_each<Rhs>(self, rhs: [Rhs; N]) -> [<T as Shr<Rhs>>::Output; N]
where T: Shr<Rhs>;
fn bitor_each<Rhs>(self, rhs: [Rhs; N]) -> [<T as BitOr<Rhs>>::Output; N]
where T: BitOr<Rhs>;
fn bitand_each<Rhs>(self, rhs: [Rhs; N]) -> [<T as BitAnd<Rhs>>::Output; N]
where T: BitAnd<Rhs>;
fn bitxor_each<Rhs>(self, rhs: [Rhs; N]) -> [<T as BitXor<Rhs>>::Output; N]
where T: BitXor<Rhs>;
fn add_assign_each<Rhs>(&mut self, rhs: [Rhs; N])
where T: AddAssign<Rhs>;
fn sub_assign_each<Rhs>(&mut self, rhs: [Rhs; N])
where T: SubAssign<Rhs>;
fn mul_assign_each<Rhs>(&mut self, rhs: [Rhs; N])
where T: MulAssign<Rhs>;
fn div_assign_each<Rhs>(&mut self, rhs: [Rhs; N])
where T: DivAssign<Rhs>;
fn rem_assign_each<Rhs>(&mut self, rhs: [Rhs; N])
where T: RemAssign<Rhs>;
fn shl_assign_each<Rhs>(&mut self, rhs: [Rhs; N])
where T: ShlAssign<Rhs>;
fn shr_assign_each<Rhs>(&mut self, rhs: [Rhs; N])
where T: ShrAssign<Rhs>;
fn bitor_assign_each<Rhs>(&mut self, rhs: [Rhs; N])
where T: BitOrAssign<Rhs>;
fn bitand_assign_each<Rhs>(&mut self, rhs: [Rhs; N])
where T: BitAndAssign<Rhs>;
fn bitxor_assign_each<Rhs>(&mut self, rhs: [Rhs; N])
where T: BitXorAssign<Rhs>;
fn try_mul_dot<Rhs>(self, rhs: [Rhs; N]) -> Option<<T as Mul<Rhs>>::Output>
where T: Mul<Rhs, Output: AddAssign>;
fn mul_dot_bias<Rhs>(
self,
rhs: [Rhs; N],
bias: <T as Mul<Rhs>>::Output
) -> <T as Mul<Rhs>>::Output
where T: Mul<Rhs, Output: AddAssign>;
fn mul_outer<Rhs, const M: usize>(
&self,
rhs: &[Rhs; M]
) -> [[<T as Mul<Rhs>>::Output; M]; N]
where T: Mul<Rhs> + Copy,
Rhs: Copy;
fn mul_cross<Rhs>(&self, rhs: [&[Rhs; N]; { _ }]) -> [<T as Sub>::Output; N]
where T: MulAssign<Rhs> + Sub + Copy,
Rhs: Copy;
fn try_magnitude_squared(self) -> Option<<T as Mul<T>>::Output>
where T: Mul<T, Output: AddAssign> + Copy;
fn chain<const M: usize>(self, rhs: [T; M]) -> [T; { _ }];
fn rchain<const M: usize>(self, rhs: [T; M]) -> [T; { _ }];
fn into_rotate_left(self, n: usize) -> Self;
fn into_rotate_right(self, n: usize) -> Self;
fn into_shift_many_left<const M: usize>(
self,
items: [T; M]
) -> ([T; M], Self);
fn into_shift_many_right<const M: usize>(
self,
items: [T; M]
) -> (Self, [T; M]);
fn into_shift_left(self, item: T) -> (T, Self);
fn into_shift_right(self, item: T) -> (Self, T);
fn rotate_left2(&mut self, n: usize);
fn rotate_right2(&mut self, n: usize);
fn shift_many_left<const M: usize>(&mut self, items: [T; M]) -> [T; M];
fn shift_many_right<const M: usize>(&mut self, items: [T; M]) -> [T; M];
fn shift_left(&mut self, item: T) -> T;
fn shift_right(&mut self, item: T) -> T;
fn spread<const M: usize>(self) -> ([[T; { _ }]; M], [T; { _ }])
where [(); { _ }]:;
fn spread_ref<const M: usize>(
&self
) -> ([&[Padded<T, M>; { _ }]; M], &[T; { _ }])
where [(); { _ }]:;
fn spread_mut<const M: usize>(
&mut self
) -> ([&mut [Padded<T, M>; { _ }]; M], &mut [T; { _ }])
where [(); { _ }]:;
fn rspread<const M: usize>(self) -> ([T; { _ }], [[T; { _ }]; M])
where [(); { _ }]:,
T: Copy;
fn rspread_ref<const M: usize>(
&self
) -> (&[T; { _ }], [&[Padded<T, M>; { _ }]; M])
where [(); { _ }]:;
fn rspread_mut<const M: usize>(
&mut self
) -> (&mut [T; { _ }], [&mut [Padded<T, M>; { _ }]; M])
where [(); { _ }]:;
fn spread_exact<const M: usize>(self) -> [[T; { _ }]; M]
where [(); { _ }]:;
fn spread_exact_ref<const M: usize>(&self) -> [&[Padded<T, M>; { _ }]; M]
where [(); { _ }]:;
fn spread_exact_mut<const M: usize>(
&mut self
) -> [&mut [Padded<T, M>; { _ }]; M]
where [(); { _ }]:;
fn chunks<const M: usize>(self) -> ([[T; M]; { _ }], [T; { _ }])
where [(); { _ }]:;
fn chunks_ref<const M: usize>(&self) -> (&[[T; M]; { _ }], &[T; { _ }])
where [(); { _ }]:;
fn chunks_mut<const M: usize>(
&mut self
) -> (&mut [[T; M]; { _ }], &mut [T; { _ }])
where [(); { _ }]:;
fn rchunks<const M: usize>(self) -> ([T; { _ }], [[T; M]; { _ }])
where [(); { _ }]:;
fn rchunks_ref<const M: usize>(&self) -> (&[T; { _ }], &[[T; M]; { _ }])
where [(); { _ }]:;
fn rchunks_mut<const M: usize>(
&mut self
) -> (&mut [T; { _ }], &mut [[T; M]; { _ }])
where [(); { _ }]:;
fn chunks_exact<const M: usize>(self) -> [[T; M]; { _ }]
where [(); { _ }]:;
fn chunks_exact_ref<const M: usize>(&self) -> &[[T; M]; { _ }]
where [(); { _ }]:;
fn chunks_exact_mut<const M: usize>(&mut self) -> &mut [[T; M]; { _ }]
where [(); { _ }]:;
fn array_simd<const M: usize>(self) -> ([Simd<T, M>; { _ }], [T; { _ }])
where T: SimdElement,
LaneCount<M>: SupportedLaneCount,
[(); { _ }]:;
fn array_rsimd<const M: usize>(self) -> ([T; { _ }], [Simd<T, M>; { _ }])
where T: SimdElement,
LaneCount<M>: SupportedLaneCount,
[(); { _ }]:;
fn array_simd_exact<const M: usize>(self) -> [Simd<T, M>; { _ }]
where T: SimdElement,
LaneCount<M>: SupportedLaneCount,
[(); { _ }]:;
fn split_array<const M: usize>(self) -> ([T; M], [T; { _ }])
where [(); { _ }]:;
fn split_array_ref2<const M: usize>(&self) -> (&[T; M], &[T; { _ }])
where [(); { _ }]:;
fn split_array_mut2<const M: usize>(
&mut self
) -> (&mut [T; M], &mut [T; { _ }])
where [(); { _ }]:;
fn rsplit_array<const M: usize>(self) -> ([T; { _ }], [T; M])
where [(); { _ }]:;
fn rsplit_array_ref2<const M: usize>(&self) -> (&[T; { _ }], &[T; M])
where [(); { _ }]:;
fn rsplit_array_mut2<const M: usize>(
&mut self
) -> (&mut [T; { _ }], &mut [T; M])
where [(); { _ }]:;
fn each_ref2(&self) -> [&T; N];
fn each_mut2(&mut self) -> [&mut T; N];
fn bit_reverse_permutation(&mut self)
where [(); { _ }]:;
}
Required Methods§
fn split_len(n: usize) -> (usize, usize)
fn rsplit_len(n: usize) -> (usize, usize)
fn split_ptr(&self, n: usize) -> (*const T, *const T)
fn split_mut_ptr(&mut self, n: usize) -> (*mut T, *mut T)
fn rsplit_ptr(&self, n: usize) -> (*const T, *const T)
fn rsplit_mut_ptr(&mut self, n: usize) -> (*mut T, *mut T)
fn fill<F>(fill: F) -> Self
fn rfill<F>(fill: F) -> Self
fn fill_boxed<F>(fill: F) -> Box<Self>
fn rfill_boxed<F>(fill: F) -> Box<Self>
fn fill_boxed_in<F, A>(fill: F, alloc: A) -> Box<Self, A>
fn rfill_boxed_in<F, A>(fill: F, alloc: A) -> Box<Self, A>
fn truncate<const M: usize>(self) -> [T; M]
fn rtruncate<const M: usize>(self) -> [T; M]
fn truncate_ref<const M: usize>(&self) -> &[T; M]
fn rtruncate_ref<const M: usize>(&self) -> &[T; M]
fn truncate_mut<const M: usize>(&mut self) -> &mut [T; M]
fn rtruncate_mut<const M: usize>(&mut self) -> &mut [T; M]
fn resize<const M: usize, F>(self, fill: F) -> [T; M]
fn rresize<const M: usize, F>(self, fill: F) -> [T; M]
fn extend<const M: usize, F>(self, fill: F) -> [T; M]
fn rextend<const M: usize, F>(self, fill: F) -> [T; M]
fn reformulate_length<const M: usize>(self) -> [T; M]
fn reformulate_length_ref<const M: usize>(&self) -> &[T; M]
fn reformulate_length_mut<const M: usize>(&mut self) -> &mut [T; M]
fn try_reformulate_length<const M: usize>(self) -> Result<[T; M], Self>
fn try_reformulate_length_ref<const M: usize>(&self) -> Option<&[T; M]>
fn try_reformulate_length_mut<const M: usize>(&mut self) -> Option<&mut [T; M]>
fn into_collumn(self) -> [[T; 1]; N]
fn as_collumn(&self) -> &[[T; 1]; N]
fn as_collumn_mut(&mut self) -> &mut [[T; 1]; N]
sourcefn map2<Map>(self, map: Map) -> [Map::Output; N]
fn map2<Map>(self, map: Map) -> [Map::Output; N]
Maps all values of an array with a given function.
§Example
use array__ops::*;
const A: [u8; 4] = [1, 2, 3, 4];
let b = A.map2(|b| -(b as i8));
assert_eq!(b, [-1, -2, -3, -4]);
fn map_outer<Map>(&self, map: Map) -> [[Map::Output; N]; N]
fn comap<Map, Rhs>(self, rhs: [Rhs; N], map: Map) -> [Map::Output; N]
fn comap_outer<Map, Rhs, const M: usize>( &self, rhs: &[Rhs; M], map: Map ) -> [[Map::Output; M]; N]
fn flat_map<Map, O, const M: usize>(self, map: Map) -> [O; { _ }]
fn map_assign<Map>(&mut self, map: Map)where
Map: FnMut(T) -> T,
sourcefn zip<Z>(self, other: [Z; N]) -> [(T, Z); N]
fn zip<Z>(self, other: [Z; N]) -> [(T, Z); N]
Combines two arrays with possibly different items into parallel, where each element lines up in the same position.
This method can be executed at compile-time, as opposed to the standard-library method.
§Example
use array__ops::*;
const A: [u8; 4] = [4, 3, 2, 1];
const B: [&str; 4] = ["four", "three", "two", "one"];
let c = A.zip(B);
assert_eq!(c, [(4, "four"), (3, "three"), (2, "two"), (1, "one")]);
fn zip_outer<Z, const M: usize>(&self, other: &[Z; M]) -> [[(T, Z); M]; N]
fn enumerate(self) -> [(usize, T); N]
fn diagonal<const H: usize, const W: usize>(self) -> [[T; W]; H]
sourcefn differentiate(&mut self)
fn differentiate(&mut self)
Differentiates array (discrete calculus)
§Example
use array__ops::*;
let mut a = [1, 2, 3];
a.differentiate();
assert_eq!(a, [1, 2 - 1, 3 - 2]);
sourcefn integrate(&mut self)
fn integrate(&mut self)
Integrates array (discrete calculus)
§Example
use array__ops::*;
let mut a = [1, 2, 3];
a.integrate();
assert_eq!(a, [1, 1 + 2, 1 + 2 + 3])
sourcefn reduce<R>(self, reduce: R) -> Option<T>where
R: FnMut(T, T) -> T,
fn reduce<R>(self, reduce: R) -> Option<T>where
R: FnMut(T, T) -> T,
Reduces elements in array into one element, using a given operand
§Example
use array__ops::ArrayOps;
const A: [u8; 3] = [1, 2, 3];
let r: u8 = A.reduce(|a, b| a + b).unwrap();
assert_eq!(r, 6);
fn try_sum(self) -> Option<T>where
T: AddAssign,
fn sum_from<S>(self, from: S) -> Swhere
S: AddAssign<T>,
fn try_product(self) -> Option<T>where
T: MulAssign,
fn product_from<P>(self, from: P) -> Pwhere
P: MulAssign<T>,
fn max(self) -> Option<T>where
T: Ord,
fn min(self) -> Option<T>where
T: Ord,
fn first_max(self) -> Option<T>where
T: PartialOrd<T>,
fn first_min(self) -> Option<T>where
T: PartialOrd<T>,
fn argmax(&self) -> Option<usize>where
T: PartialOrd<T>,
fn argmin(&self) -> Option<usize>where
T: PartialOrd<T>,
fn add_all<Rhs>(self, rhs: Rhs) -> [<T as Add<Rhs>>::Output; N]
fn sub_all<Rhs>(self, rhs: Rhs) -> [<T as Sub<Rhs>>::Output; N]
fn mul_all<Rhs>(self, rhs: Rhs) -> [<T as Mul<Rhs>>::Output; N]
fn div_all<Rhs>(self, rhs: Rhs) -> [<T as Div<Rhs>>::Output; N]
fn rem_all<Rhs>(self, rhs: Rhs) -> [<T as Rem<Rhs>>::Output; N]
fn shl_all<Rhs>(self, rhs: Rhs) -> [<T as Shl<Rhs>>::Output; N]
fn shr_all<Rhs>(self, rhs: Rhs) -> [<T as Shr<Rhs>>::Output; N]
fn bitor_all<Rhs>(self, rhs: Rhs) -> [<T as BitOr<Rhs>>::Output; N]
fn bitand_all<Rhs>(self, rhs: Rhs) -> [<T as BitAnd<Rhs>>::Output; N]
fn bitxor_all<Rhs>(self, rhs: Rhs) -> [<T as BitXor<Rhs>>::Output; N]
fn add_assign_all<Rhs>(&mut self, rhs: Rhs)
fn sub_assign_all<Rhs>(&mut self, rhs: Rhs)
fn mul_assign_all<Rhs>(&mut self, rhs: Rhs)
fn div_assign_all<Rhs>(&mut self, rhs: Rhs)
fn rem_assign_all<Rhs>(&mut self, rhs: Rhs)
fn shl_assign_all<Rhs>(&mut self, rhs: Rhs)
fn shr_assign_all<Rhs>(&mut self, rhs: Rhs)
fn bitor_assign_all<Rhs>(&mut self, rhs: Rhs)where
T: BitOrAssign<Rhs>,
Rhs: Copy,
fn bitand_assign_all<Rhs>(&mut self, rhs: Rhs)where
T: BitAndAssign<Rhs>,
Rhs: Copy,
fn bitxor_assign_all<Rhs>(&mut self, rhs: Rhs)where
T: BitXorAssign<Rhs>,
Rhs: Copy,
fn add_all_neg<Rhs>(self, rhs: Rhs) -> [<Rhs as Sub<T>>::Output; N]
fn mul_all_inv<Rhs>(self, rhs: Rhs) -> [<Rhs as Div<T>>::Output; N]
fn neg_all(self) -> [<T as Neg>::Output; N]where
T: Neg,
fn neg_assign_all(&mut self)where
T: Neg<Output = T>,
fn add_each<Rhs>(self, rhs: [Rhs; N]) -> [<T as Add<Rhs>>::Output; N]where
T: Add<Rhs>,
fn sub_each<Rhs>(self, rhs: [Rhs; N]) -> [<T as Sub<Rhs>>::Output; N]where
T: Sub<Rhs>,
fn mul_each<Rhs>(self, rhs: [Rhs; N]) -> [<T as Mul<Rhs>>::Output; N]where
T: Mul<Rhs>,
fn div_each<Rhs>(self, rhs: [Rhs; N]) -> [<T as Div<Rhs>>::Output; N]where
T: Div<Rhs>,
fn rem_each<Rhs>(self, rhs: [Rhs; N]) -> [<T as Rem<Rhs>>::Output; N]where
T: Rem<Rhs>,
fn shl_each<Rhs>(self, rhs: [Rhs; N]) -> [<T as Shl<Rhs>>::Output; N]where
T: Shl<Rhs>,
fn shr_each<Rhs>(self, rhs: [Rhs; N]) -> [<T as Shr<Rhs>>::Output; N]where
T: Shr<Rhs>,
fn bitor_each<Rhs>(self, rhs: [Rhs; N]) -> [<T as BitOr<Rhs>>::Output; N]where
T: BitOr<Rhs>,
fn bitand_each<Rhs>(self, rhs: [Rhs; N]) -> [<T as BitAnd<Rhs>>::Output; N]where
T: BitAnd<Rhs>,
fn bitxor_each<Rhs>(self, rhs: [Rhs; N]) -> [<T as BitXor<Rhs>>::Output; N]where
T: BitXor<Rhs>,
fn add_assign_each<Rhs>(&mut self, rhs: [Rhs; N])where
T: AddAssign<Rhs>,
fn sub_assign_each<Rhs>(&mut self, rhs: [Rhs; N])where
T: SubAssign<Rhs>,
fn mul_assign_each<Rhs>(&mut self, rhs: [Rhs; N])where
T: MulAssign<Rhs>,
fn div_assign_each<Rhs>(&mut self, rhs: [Rhs; N])where
T: DivAssign<Rhs>,
fn rem_assign_each<Rhs>(&mut self, rhs: [Rhs; N])where
T: RemAssign<Rhs>,
fn shl_assign_each<Rhs>(&mut self, rhs: [Rhs; N])where
T: ShlAssign<Rhs>,
fn shr_assign_each<Rhs>(&mut self, rhs: [Rhs; N])where
T: ShrAssign<Rhs>,
fn bitor_assign_each<Rhs>(&mut self, rhs: [Rhs; N])where
T: BitOrAssign<Rhs>,
fn bitand_assign_each<Rhs>(&mut self, rhs: [Rhs; N])where
T: BitAndAssign<Rhs>,
fn bitxor_assign_each<Rhs>(&mut self, rhs: [Rhs; N])where
T: BitXorAssign<Rhs>,
fn try_mul_dot<Rhs>(self, rhs: [Rhs; N]) -> Option<<T as Mul<Rhs>>::Output>
fn mul_dot_bias<Rhs>( self, rhs: [Rhs; N], bias: <T as Mul<Rhs>>::Output ) -> <T as Mul<Rhs>>::Output
fn mul_outer<Rhs, const M: usize>( &self, rhs: &[Rhs; M] ) -> [[<T as Mul<Rhs>>::Output; M]; N]
sourcefn mul_cross<Rhs>(&self, rhs: [&[Rhs; N]; { _ }]) -> [<T as Sub>::Output; N]
fn mul_cross<Rhs>(&self, rhs: [&[Rhs; N]; { _ }]) -> [<T as Sub>::Output; N]
Computes the general cross-product of the two arrays (as if vectors, in the mathematical sense).
§Example
#![feature(generic_const_exprs)]
use array__ops::*;
const U: [f64; 3] = [1.0, 0.0, 0.0];
const V: [f64; 3] = [0.0, 1.0, 0.0];
let w = U.mul_cross([&V]);
assert_eq!(w, [0.0, 0.0, 1.0]);
fn try_magnitude_squared(self) -> Option<<T as Mul<T>>::Output>
sourcefn chain<const M: usize>(self, rhs: [T; M]) -> [T; { _ }]
fn chain<const M: usize>(self, rhs: [T; M]) -> [T; { _ }]
Chains two arrays with the same item together.
§Example
use array__ops::*;
let a = ["one", "two"];
let b = ["three"];
assert_eq!(a.chain(b), ["one", "two", "three"]);
sourcefn rchain<const M: usize>(self, rhs: [T; M]) -> [T; { _ }]
fn rchain<const M: usize>(self, rhs: [T; M]) -> [T; { _ }]
Chains two arrays with the same item together in reverse.
§Example
use array__ops::*;
let a = ["two", "three"];
let b = ["one"];
assert_eq!(a.rchain(b), ["one", "two", "three"]);
fn into_rotate_left(self, n: usize) -> Self
fn into_rotate_right(self, n: usize) -> Self
fn into_shift_many_left<const M: usize>(self, items: [T; M]) -> ([T; M], Self)
fn into_shift_many_right<const M: usize>(self, items: [T; M]) -> (Self, [T; M])
fn into_shift_left(self, item: T) -> (T, Self)
fn into_shift_right(self, item: T) -> (Self, T)
fn rotate_left2(&mut self, n: usize)
fn rotate_right2(&mut self, n: usize)
fn shift_many_left<const M: usize>(&mut self, items: [T; M]) -> [T; M]
fn shift_many_right<const M: usize>(&mut self, items: [T; M]) -> [T; M]
fn shift_left(&mut self, item: T) -> T
fn shift_right(&mut self, item: T) -> T
sourcefn spread<const M: usize>(self) -> ([[T; { _ }]; M], [T; { _ }])
fn spread<const M: usize>(self) -> ([[T; { _ }]; M], [T; { _ }])
Distributes items of an array equally across a given width, then provides the rest as a separate array.
§Example
#![feature(generic_const_exprs)]
#![feature(generic_arg_infer)]
use array__ops::*;
let array = ["ping 1", "pong 1", "ping 2", "pong 2", "ping 3", "pong 3", "uhh..."];
let ([ping, pong], rest) = array.spread::<2>();
assert_eq!(ping, ["ping 1", "ping 2", "ping 3"]);
assert_eq!(pong, ["pong 1", "pong 2", "pong 3"]);
assert_eq!(rest, ["uhh..."]);
sourcefn spread_ref<const M: usize>(
&self
) -> ([&[Padded<T, M>; { _ }]; M], &[T; { _ }])
fn spread_ref<const M: usize>( &self ) -> ([&[Padded<T, M>; { _ }]; M], &[T; { _ }])
Distributes items of an array-slice equally across a given width, then provides the rest as a separate array-slice.
The spread-out slices are given in padded arrays. Each padded item can be borrowed into a reference to the array’s item.
sourcefn spread_mut<const M: usize>(
&mut self
) -> ([&mut [Padded<T, M>; { _ }]; M], &mut [T; { _ }])
fn spread_mut<const M: usize>( &mut self ) -> ([&mut [Padded<T, M>; { _ }]; M], &mut [T; { _ }])
Distributes items of a mutable array-slice equally across a given width, then provides the rest as a separate mutable array-slice.
The spread-out slices are given in padded arrays. Each padded item can be borrowed into a reference to the array’s item.
§Example
#![feature(generic_const_exprs)]
#![feature(generic_arg_infer)]
use array__ops::*;
let mut array = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20"];
let (threes, _) = array.spread_mut::<3>();
for fizz in threes.into_iter().last().unwrap()
{
**fizz = "fizz";
}
let (fives, _) = array.spread_mut::<5>();
for buzz in fives.into_iter().last().unwrap()
{
**buzz = "buzz";
}
let (fifteens, _) = array.spread_mut::<15>();
for fizzbuzz in fifteens.into_iter().last().unwrap()
{
**fizzbuzz = "fizzbuzz";
}
assert_eq!(array, ["1", "2", "fizz", "4", "buzz", "fizz", "7", "8", "fizz", "buzz", "11", "fizz", "13", "14", "fizzbuzz", "16", "17", "fizz", "19", "buzz"]);
sourcefn rspread<const M: usize>(self) -> ([T; { _ }], [[T; { _ }]; M])
fn rspread<const M: usize>(self) -> ([T; { _ }], [[T; { _ }]; M])
Distributes items of an array equally across a given width, then provides the leftmost rest as a separate array.
sourcefn rspread_ref<const M: usize>(
&self
) -> (&[T; { _ }], [&[Padded<T, M>; { _ }]; M])
fn rspread_ref<const M: usize>( &self ) -> (&[T; { _ }], [&[Padded<T, M>; { _ }]; M])
Distributes items of an array-slice equally across a given width, then provides the leftmost rest as a separate array-slice.
The spread-out slices are given in padded arrays. Each padded item can be borrowed into a reference to the array’s item.
§Example
#![feature(generic_const_exprs)]
#![feature(generic_arg_infer)]
#![feature(array_methods)]
use array__ops::*;
let array = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];
let (zero, [odd, even]) = array.rspread_ref::<2>();
assert_eq!(*zero, [0]);
assert_eq!(odd.each_ref().map(|padding| **padding), [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]);
assert_eq!(even.each_ref().map(|padding| **padding), [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]);
sourcefn rspread_mut<const M: usize>(
&mut self
) -> (&mut [T; { _ }], [&mut [Padded<T, M>; { _ }]; M])
fn rspread_mut<const M: usize>( &mut self ) -> (&mut [T; { _ }], [&mut [Padded<T, M>; { _ }]; M])
Distributes items of a mutable array-slice equally across a given width, then provides the leftmost rest as a separate mutable array-slice.
The spread-out slices are given in padded arrays. Each padded item can be borrowed into a reference to the array’s item.
§Example
#![feature(generic_const_exprs)]
#![feature(generic_arg_infer)]
#![feature(array_methods)]
use array__ops::*;
let mut array = ["the", "beat", "goes", "1", "2", "3", "4", "5", "6", "7", "8"];
let (start, [boots, n, cats, and]) = array.rspread_mut::<4>();
for boots in boots
{
**boots = "boots";
}
for n in n
{
**n = "n";
}
for cats in cats
{
**cats = "cats";
}
for and in and
{
**and = "and";
}
assert_eq!(array, ["the", "beat", "goes", "boots", "n", "cats", "and", "boots", "n", "cats", "and"]);
sourcefn spread_exact<const M: usize>(self) -> [[T; { _ }]; M]
fn spread_exact<const M: usize>(self) -> [[T; { _ }]; M]
Distributes items of an array equally across a given width, with no rest.
The width must be a factor of the array length, otherwise it will not compile.
§Example
#![feature(generic_const_exprs)]
#![feature(generic_arg_infer)]
use array__ops::*;
let array = *b"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ";
let [lower_case, upper_case] = array.spread_exact::<2>();
assert_eq!(lower_case, *b"abcdefghijklmnopqrstuvwxyz");
assert_eq!(upper_case, *b"ABCDEFGHIJKLMNOPQRSTUVWXYZ");
sourcefn spread_exact_ref<const M: usize>(&self) -> [&[Padded<T, M>; { _ }]; M]
fn spread_exact_ref<const M: usize>(&self) -> [&[Padded<T, M>; { _ }]; M]
Distributes items of an array-slice equally across a given width, with no rest.
The width must be a factor of the array length, otherwise it will not compile.
The spread-out slices are given in padded arrays. Each padded item can be borrowed into a reference to the array’s item.
§Example
#![feature(generic_const_exprs)]
#![feature(generic_arg_infer)]
#![feature(array_methods)]
use array__ops::*;
let statement = ["s", "he", "be", "lie", "ve", "d"];
let [interpretation2, interpretation1] = statement.spread_exact_ref::<2>();
assert_eq!(interpretation1, &["he", "lie", "d"]);
assert_eq!(interpretation2, &["s", "be", "ve"]);
sourcefn spread_exact_mut<const M: usize>(
&mut self
) -> [&mut [Padded<T, M>; { _ }]; M]
fn spread_exact_mut<const M: usize>( &mut self ) -> [&mut [Padded<T, M>; { _ }]; M]
Distributes items of a mutable array-slice equally across a given width, with no rest.
The width must be a factor of the array length, otherwise it will not compile.
The spread-out slices are given in padded arrays. Each padded item can be borrowed into a reference to the array’s item.
§Example
#![feature(generic_const_exprs)]
#![feature(generic_arg_infer)]
#![feature(array_methods)]
use array__ops::*;
let mut array = *b"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ";
let [lower_case, upper_case] = array.spread_exact_mut::<2>();
assert_eq!(lower_case.each_ref().map(|padding| padding.borrow()), b"abcdefghijklmnopqrstuvwxyz".each_ref());
assert_eq!(upper_case.each_ref().map(|padding| padding.borrow()), b"ABCDEFGHIJKLMNOPQRSTUVWXYZ".each_ref());
for c in upper_case
{
**c = b'_';
}
assert_eq!(array, *b"a_b_c_d_e_f_g_h_i_j_k_l_m_n_o_p_q_r_s_t_u_v_w_x_y_z_")
sourcefn chunks<const M: usize>(self) -> ([[T; M]; { _ }], [T; { _ }])
fn chunks<const M: usize>(self) -> ([[T; M]; { _ }], [T; { _ }])
Divides an array into chunks, then yielding the rest in a separate array.
§Example
#![feature(generic_const_exprs)]
#![feature(generic_arg_infer)]
use array__ops::*;
let array = ["carrot", "potato", "beet", "tomato", "kiwi", "banana", "cherry", "peach", "strawberry", "nine volt batteries"];
let ([root_vegetables, technically_berries, stone_fruits], not_for_human_consumption) = array.chunks::<3>();
assert_eq!(root_vegetables, ["carrot", "potato", "beet"]);
assert_eq!(technically_berries, ["tomato", "kiwi", "banana"]);
assert_eq!(stone_fruits, ["cherry", "peach", "strawberry"]);
assert_eq!(not_for_human_consumption, ["nine volt batteries"]);
sourcefn chunks_ref<const M: usize>(&self) -> (&[[T; M]; { _ }], &[T; { _ }])
fn chunks_ref<const M: usize>(&self) -> (&[[T; M]; { _ }], &[T; { _ }])
Divides an array-slice into chunks, then yielding the rest in a separate array-slice.
§Example
#![feature(generic_const_exprs)]
#![feature(generic_arg_infer)]
use array__ops::*;
let transistors = ["2N3904", "2N2222A", "BC107", "AC127", "OC7", "NKT275", "2SK30A", "2N5458", "J108", "2N7000", "BS170"];
let ([silicon_bjts, germanium_bjts, jfets], mosfets) = transistors.chunks_ref::<3>();
assert_eq!(silicon_bjts, &["2N3904", "2N2222A", "BC107"]);
assert_eq!(germanium_bjts, &["AC127", "OC7", "NKT275"]);
assert_eq!(jfets, &["2SK30A", "2N5458", "J108"]);
assert_eq!(mosfets, &["2N7000", "BS170"]);
sourcefn chunks_mut<const M: usize>(
&mut self
) -> (&mut [[T; M]; { _ }], &mut [T; { _ }])
fn chunks_mut<const M: usize>( &mut self ) -> (&mut [[T; M]; { _ }], &mut [T; { _ }])
Divides a mutable array-slice into chunks, then yielding the rest in a separate mutable array-slice.
§Example
#![feature(generic_const_exprs)]
#![feature(generic_arg_infer)]
use array__ops::*;
let mut array = [0, 1, 0, 1, 0, 1, 6];
let (pairs, last) = array.chunks_mut::<2>();
for (i, pair) in pairs.into_iter().enumerate()
{
for number in pair
{
*number += i*2;
}
}
assert_eq!(array, [0, 1, 2, 3, 4, 5, 6]);
sourcefn rchunks<const M: usize>(self) -> ([T; { _ }], [[T; M]; { _ }])
fn rchunks<const M: usize>(self) -> ([T; { _ }], [[T; M]; { _ }])
Divides a mutable array-slice into chunks, then yielding the leftmost rest in a separate mutable array-slice.
sourcefn rchunks_ref<const M: usize>(&self) -> (&[T; { _ }], &[[T; M]; { _ }])
fn rchunks_ref<const M: usize>(&self) -> (&[T; { _ }], &[[T; M]; { _ }])
Divides an array-slice into chunks, then yielding the leftmost rest in a separate array-slice.
sourcefn rchunks_mut<const M: usize>(
&mut self
) -> (&mut [T; { _ }], &mut [[T; M]; { _ }])
fn rchunks_mut<const M: usize>( &mut self ) -> (&mut [T; { _ }], &mut [[T; M]; { _ }])
Divides a mutable array-slice into chunks, then yielding the leftmost rest in a separate array-slice.
sourcefn chunks_exact<const M: usize>(self) -> [[T; M]; { _ }]
fn chunks_exact<const M: usize>(self) -> [[T; M]; { _ }]
Divides an array into chunks, with no rest.
The chunk length must be a factor of the array length, otherwise it will not compile.
§Example
#![feature(generic_const_exprs)]
#![feature(generic_arg_infer)]
use array__ops::*;
let array = [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9];
let [lower_half, upper_half] = array.chunks_exact::<5>();
assert_eq!(lower_half, [0.0, 0.1, 0.2, 0.3, 0.4]);
assert_eq!(upper_half, [0.5, 0.6, 0.7, 0.8, 0.9]);
sourcefn chunks_exact_ref<const M: usize>(&self) -> &[[T; M]; { _ }]
fn chunks_exact_ref<const M: usize>(&self) -> &[[T; M]; { _ }]
Divides an array-slice into chunks, with no rest.
The chunk length must be a factor of the array length, otherwise it will not compile.
§Example
#![feature(generic_const_exprs)]
#![feature(generic_arg_infer)]
use array__ops::*;
let array = [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9];
let [lower_half, upper_half] = array.chunks_exact_ref::<5>();
assert_eq!(lower_half, &[0.0, 0.1, 0.2, 0.3, 0.4]);
assert_eq!(upper_half, &[0.5, 0.6, 0.7, 0.8, 0.9]);
sourcefn chunks_exact_mut<const M: usize>(&mut self) -> &mut [[T; M]; { _ }]
fn chunks_exact_mut<const M: usize>(&mut self) -> &mut [[T; M]; { _ }]
Divides a mutable array-slice into chunks, with no rest.
The chunk length must be a factor of the array length, otherwise it will not compile.
fn array_simd<const M: usize>(self) -> ([Simd<T, M>; { _ }], [T; { _ }])
fn array_rsimd<const M: usize>(self) -> ([T; { _ }], [Simd<T, M>; { _ }])
fn array_simd_exact<const M: usize>(self) -> [Simd<T, M>; { _ }]
sourcefn split_array<const M: usize>(self) -> ([T; M], [T; { _ }])
fn split_array<const M: usize>(self) -> ([T; M], [T; { _ }])
Splits an array at a chosen index.
sourcefn split_array_ref2<const M: usize>(&self) -> (&[T; M], &[T; { _ }])
fn split_array_ref2<const M: usize>(&self) -> (&[T; M], &[T; { _ }])
Splits an array at a chosen index as array-slices.
sourcefn split_array_mut2<const M: usize>(&mut self) -> (&mut [T; M], &mut [T; { _ }])
fn split_array_mut2<const M: usize>(&mut self) -> (&mut [T; M], &mut [T; { _ }])
Splits an array at a chosen index as mutable array-slices.
sourcefn rsplit_array<const M: usize>(self) -> ([T; { _ }], [T; M])
fn rsplit_array<const M: usize>(self) -> ([T; { _ }], [T; M])
Splits an array at a chosen index, where the index goes from right to left.
sourcefn rsplit_array_ref2<const M: usize>(&self) -> (&[T; { _ }], &[T; M])
fn rsplit_array_ref2<const M: usize>(&self) -> (&[T; { _ }], &[T; M])
Splits an array at a chosen index as array-slices, where the index goes from right to left.
sourcefn rsplit_array_mut2<const M: usize>(
&mut self
) -> (&mut [T; { _ }], &mut [T; M])
fn rsplit_array_mut2<const M: usize>( &mut self ) -> (&mut [T; { _ }], &mut [T; M])
Splits an array at a chosen index as mutable array-slices, where the index goes from right to left.
fn each_ref2(&self) -> [&T; N]
fn each_mut2(&mut self) -> [&mut T; N]
sourcefn bit_reverse_permutation(&mut self)
fn bit_reverse_permutation(&mut self)
Performs the bit-reverse permutation. Length must be a power of 2.
§Example
use array__ops::*;
let mut arr = [0b000, 0b001, 0b010, 0b011, 0b100, 0b101, 0b110, 0b111];
arr.bit_reverse_permutation();
assert_eq!(arr, [0b000, 0b100, 0b010, 0b110, 0b001, 0b101, 0b011, 0b111])