Struct nslice::MinSlice[][src]

pub struct MinSlice<T, const N: usize> {
    pub head: [T; N],
    pub tail: [T],
}
Expand description

A reference to a region of memory which is known to contain N or more elements of type T.

Much like [T] itself, it is not possible to construct an owned MinSlice. MinSlice is merely a way of reinterpreting an existing slice (&[T] or &mut [T]), and it is exactly the same size as a slice: one pointer and one usize.

Fields

head: [T; N]

The bounded region of memory. Exactly N Ts.

tail: [T]

Zero or more remaining Ts after the N in the bounded region.

Implementations

Produce a &MinSlice from a slice of Ts. Returns None if there are not enough elements in slice.

Produce a &mut MinSlice from a mutable slice of Ts. Returns None if there are not enough elements in slice.

Produce a &MinSlice from a slice of Ts without checking its length.

Safety

The caller is responsible for upholding the length invariant slice.len() >= N, in addition to all normal slice invariants.

Produce a &mut MinSlice from a slice of Ts without checking its length.

Safety

The caller is responsible for upholding the length invariant slice.len() >= N, in addition to all normal slice invariants.

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