Trait SplitArray

Source
pub trait SplitArray<const LEN: usize> {
    type Output<const OUT_SIZE: usize>: SplitArray<OUT_SIZE>;

    // Required methods
    fn split_arr<const LEFT: usize>(
        &self,
    ) -> (&Self::Output<LEFT>, &Self::Output<{ _ }>)
       where [(); { _ }]:;
    fn split_arr_mut<const LEFT: usize>(
        &mut self,
    ) -> (&mut Self::Output<LEFT>, &mut Self::Output<{ _ }>)
       where [(); { _ }]:;
}
Expand description

Split array references in two with compile-time size validation.

Required Associated Types§

Source

type Output<const OUT_SIZE: usize>: SplitArray<OUT_SIZE>

The result of a split.

Required Methods§

Source

fn split_arr<const LEFT: usize>( &self, ) -> (&Self::Output<LEFT>, &Self::Output<{ _ }>)
where [(); { _ }]:,

Split an array reference into a reference to the left half and a reference to the right half. The sizes of the halves are validated at compile time.

Source

fn split_arr_mut<const LEFT: usize>( &mut self, ) -> (&mut Self::Output<LEFT>, &mut Self::Output<{ _ }>)
where [(); { _ }]:,

Mutable version of Self::split_arr

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 LEN: usize> SplitArray<LEN> for [T; LEN]

Source§

type Output<const OUT_SIZE: usize> = [T; OUT_SIZE]

Source§

fn split_arr<const LEFT: usize>(&self) -> (&[T; LEFT], &[T; { _ }])
where [(); { _ }]:,

Source§

fn split_arr_mut<const LEFT: usize>( &mut self, ) -> (&mut [T; LEFT], &mut [T; { _ }])
where [(); { _ }]:,

Implementors§