Struct cl_array_ext::SliceN [−][src]
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
pub fn increase_mut<const M: usize>(
&mut self
) -> Result<&mut SliceN<T, { N + M }>, NotEnoughEntries>
pub fn increase_mut<const M: usize>(
&mut self
) -> Result<&mut SliceN<T, { N + M }>, NotEnoughEntries>
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
type Error = NotEnoughEntries
type Error = NotEnoughEntries
The type returned in the event of a conversion error.
Performs the conversion.