Split

Trait Split 

Source
pub trait Split<T, const N: usize> {
    // Required methods
    fn split<const AT: usize>(self) -> ([T; AT], [T; { _ }]);
    fn take<const AT: usize>(self) -> [T; AT]
       where [(); { _ }]:,
             T:;
    fn drop<const AT: usize>(self) -> [T; { _ }]
       where T:;
}
Expand description

Splitting arrays up.

Required Methods§

Source

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

Splits the array into twain.

let x = [1u8, 2, 3];
let ([x], [y, z]) = x.split::<1>();
Source

fn take<const AT: usize>(self) -> [T; AT]
where [(); { _ }]:, T:,

Take AT elements, discarding the rest.

assert_eq!(range::<50>().take::<5>(), range::<5>());
Source

fn drop<const AT: usize>(self) -> [T; { _ }]
where T:,

Discard AT elements, returning the rest.

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> Split<T, N> for [T; N]

Source§

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

Source§

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

Source§

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

Implementors§