pub trait ArrayExt<T, const N: usize>: Sized {
// Required methods
fn array_split_at<const M: usize>(self) -> ([T; M], [T; { _ }])
where [T; { _ }]: Sized;
fn append<const M: usize>(self, other: [T; M]) -> [T; { _ }];
// Provided method
fn truncate<const M: usize>(self) -> [T; M]
where [T; { _ }]: Sized { ... }
}
Expand description
Trait that extends upon array
Required Methods§
Sourcefn array_split_at<const M: usize>(self) -> ([T; M], [T; { _ }])where
[T; { _ }]: Sized,
fn array_split_at<const M: usize>(self) -> ([T; M], [T; { _ }])where
[T; { _ }]: Sized,
Split an array into two smaller arrays
use cl_array_ext::ArrayExt;
let (a, b) = [1_i32, 2, 3, 4, 5].array_split_at::<3>();
assert_eq!(a, [1, 2, 3]);
assert_eq!(b, [4, 5]);
Sourcefn append<const M: usize>(self, other: [T; M]) -> [T; { _ }]
fn append<const M: usize>(self, other: [T; M]) -> [T; { _ }]
Join two arrays into one larger array
use cl_array_ext::ArrayExt;
let a = [1_i32, 2, 3].append([4, 5]);
assert_eq!(a, [1, 2, 3, 4, 5]);
Provided Methods§
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.