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]

Head of the slice, where N items are guaranteed to exist

tail: [T]

Tail of the slice, may be empty

Implementations

Increases the bounds of the slice into a new known length.

Safety

There must be at least M elements in the tail available, otherwise this will result in UB

Increases the bounds of the slice into a new known length.

Safety

There must be at least M elements in the tail available, otherwise this will result in UB

Increases the bounds of the slice into a new known length.

Errors

There should be at least M elements in the tail available, otherwise this will return an error

Increases the bounds of the slice into a new known length.

Errors

There should be at least M elements in the tail available, otherwise this will return an error

Decreases the bounds of the slice to a smaller known length.

Decreases the bounds of the slice to a smaller known length.

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

Safety

The length of the slice must be >= N, otherwise this will result in UB

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

Safety

The length of the slice must be >= N, otherwise this will result in UB

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