Skip to main content

ArrayExt

Trait ArrayExt 

Source
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§

Source

fn array_split_at<const M: usize>(self) -> ([T; M], [T; { _ }])

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]);
Source

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§

Source

fn truncate<const M: usize>(self) -> [T; M]

Take only M elements out of the array

use cl_array_ext::ArrayExt;
let a = [1, 2, 3, 4, 5].truncate::<3>();
assert_eq!(a, [1, 2, 3]);

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

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

Source§

fn array_split_at<const M: usize>(self) -> ([T; M], [T; { _ }])

Source§

fn append<const M: usize>(self, other: [T; M]) -> [T; { _ }]

Implementors§