Struct cl_array_ext::SliceN[][src]

#[repr(C)]
pub struct SliceN<T, const N: usize> { pub head: [T; N], pub tail: [T], }
Expand description

A slice with at least N elements. Can be dereferenced back into a regular slice on demand.

use cl_array_ext::SliceN;
let a: &mut [_] = &mut [1, 2, 3, 4, 5];
let b: &mut SliceN<_, 3> = a.try_into().unwrap();

b.head = [3, 2, 1];
b.tail.reverse();

assert_eq!(a, [3, 2, 1, 5, 4]);

Fields

head: [T; N]tail: [T]

Implementations

Convert a slice into one that is guaranteed to have at least N elements

Panics

The length of the slice must be >= N, otherwise this will panic

Convert a mut slice into one that is guaranteed to have at least N elements

Panics

The length of the slice must be >= N, otherwise this will panic

Trait Implementations

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more