Slice

Trait Slice 

Source
pub trait Slice<T, const N: usize> {
    // Required method
    fn slice<const RANGE: Range>(&self) -> &[T; { _ }]
       where [(); { _ }]:;
}
Expand description

Slicing arrays up.

Required Methods§

Source

fn slice<const RANGE: Range>(&self) -> &[T; { _ }]
where [(); { _ }]:,

Slices the array. Compile time checked.

let x = atools::range::<5>();
assert_eq!(*x.slice::<{ r(2..=4) }>(), [2, 3, 4]);
// x.slice::<{ r(..10) }>(); // ERROR

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

Source§

fn slice<const RANGE: Range>(&self) -> &[T; { _ }]
where [(); { _ }]:,

Implementors§