[][src]Struct fixed_slice_vec::vec::FixedSliceVec

pub struct FixedSliceVec<'a, T: Sized> { /* fields omitted */ }

Vec-like structure backed by a storage slice of possibly uninitialized data.

The maximum length (the capacity) is fixed at runtime to the length of the provided storage slice.

Implementations

impl<'a, T: Sized> FixedSliceVec<'a, T>[src]

pub fn new(storage: &'a mut [MaybeUninit<T>]) -> Self[src]

Create a SliceVec backed by a slice of possibly-uninitialized data. The backing storage slice is used as capacity for Vec-like operations,

The initial length of the SliceVec is 0.

pub fn from_bytes(bytes: &'a mut [u8]) -> FixedSliceVec<'a, T>[src]

Create a well-aligned SliceVec backed by a slice of the provided bytes. The slice is as large as possible given the item type and alignment of the provided bytes.

If you are interested in recapturing the prefix and suffix bytes on either side of the carved-out SliceVec buffer, consider using align_from_bytes instead:

let vec = fixed_slice_vec::FixedSliceVec::from_bytes(&mut bytes[..]);

The bytes are treated as if they might be uninitialized, so even if T is u8, the length of the returned SliceVec will be zero.

pub fn from_uninit_bytes(
    bytes: &'a mut [MaybeUninit<u8>]
) -> FixedSliceVec<'a, T>
[src]

Create a well-aligned SliceVec backed by a slice of the provided uninitialized bytes. The typed slice is as large as possible given its item type and the alignment of the provided bytes.

If you are interested in recapturing the prefix and suffix bytes on either side of the carved-out SliceVec buffer, consider using align_from_uninit_bytes:

pub fn align_from_bytes(
    bytes: &'a mut [u8]
) -> (&'a mut [u8], FixedSliceVec<'a, T>, &'a mut [u8])
[src]

Create a well-aligned SliceVec backed by a slice of the provided bytes. The slice is as large as possible given the item type and alignment of the provided bytes. Returns the unused prefix and suffix bytes on either side of the carved-out SliceVec.

let mut bytes = [3u8, 1, 4, 1, 5, 9];
let (prefix, vec, suffix) = fixed_slice_vec::FixedSliceVec::align_from_bytes(&mut bytes[..]);
let vec: fixed_slice_vec::FixedSliceVec<u16> = vec;

The bytes are treated as if they might be uninitialized, so even if T is u8, the length of the returned SliceVec will be zero.

pub fn align_from_uninit_bytes(
    bytes: &'a mut [MaybeUninit<u8>]
) -> (&'a mut [MaybeUninit<u8>], FixedSliceVec<'a, T>, &'a mut [MaybeUninit<u8>])
[src]

Create a well-aligned SliceVec backed by a slice of the provided bytes. The slice is as large as possible given the item type and alignment of the provided bytes. Returns the unused prefix and suffix bytes on either side of the carved-out SliceVec.

let mut bytes: [MaybeUninit<u8>; 15] = unsafe { MaybeUninit::uninit().assume_init() };
let (prefix, vec, suffix) = fixed_slice_vec::FixedSliceVec::align_from_uninit_bytes(&mut
bytes[..]);
let vec: fixed_slice_vec::FixedSliceVec<u16> = vec;

The length of the returned SliceVec will be zero.

pub fn len(&self) -> usize[src]

The length of the SliceVec. The number of initialized values that have been added to it.

pub fn capacity(&self) -> usize[src]

The maximum amount of items that can live in this SliceVec

pub fn is_empty(&self) -> bool[src]

Returns true if there are no items present.

pub fn is_full(&self) -> bool[src]

Returns true if the SliceVec is full to capacity.

pub fn try_push(&mut self, value: T) -> Result<(), TryPushError<T>>[src]

Attempt to add a value to the SliceVec.

Returns an error if there is not enough capacity to hold another item.

pub fn push(&mut self, value: T)[src]

Attempt to add a value to the SliceVec.

Panics

Panics if there is not sufficient capacity to hold another item.

pub fn pop(&mut self) -> Option<T>[src]

Remove the last item from the SliceVec.

pub fn clear(&mut self)[src]

Removes the SliceVec's tracking of all items in it while retaining the same capacity.

pub fn as_slice(&self) -> &[T][src]

Obtain an immutable slice view on the initialized portion of the SliceVec.

pub fn as_mut_slice(&mut self) -> &mut [T][src]

Obtain a mutable slice view on the initialized portion of the SliceVec.

Trait Implementations

impl<'a, T: Sized> AsMut<[T]> for FixedSliceVec<'a, T>[src]

impl<'a, T: Sized> AsRef<[T]> for FixedSliceVec<'a, T>[src]

impl<'a, T: Sized> Borrow<[T]> for FixedSliceVec<'a, T>[src]

impl<'a, T: Sized> BorrowMut<[T]> for FixedSliceVec<'a, T>[src]

impl<'a, T: Sized> Debug for FixedSliceVec<'a, T> where
    T: Debug
[src]

impl<'a, T: Sized> Deref for FixedSliceVec<'a, T>[src]

type Target = [T]

The resulting type after dereferencing.

impl<'a, T: Sized> DerefMut for FixedSliceVec<'a, T>[src]

impl<'a, T: Sized> Drop for FixedSliceVec<'a, T>[src]

impl<'a, T: Sized> Eq for FixedSliceVec<'a, T> where
    T: Eq
[src]

impl<'a, T: Sized> From<&'a mut [MaybeUninit<T>]> for FixedSliceVec<'a, T>[src]

impl<'a, T: Sized> From<&'a mut [T]> for FixedSliceVec<'a, T>[src]

impl<'a, T: Sized> Hash for FixedSliceVec<'a, T> where
    T: Hash
[src]

impl<'a, T: Sized> PartialEq<[T]> for FixedSliceVec<'a, T> where
    T: PartialEq
[src]

impl<'a, T: Sized> PartialEq<FixedSliceVec<'a, T>> for FixedSliceVec<'a, T> where
    T: PartialEq
[src]

impl<'a, T: Sized> PartialOrd<FixedSliceVec<'a, T>> for FixedSliceVec<'a, T> where
    T: PartialOrd
[src]

Auto Trait Implementations

impl<'a, T> Send for FixedSliceVec<'a, T> where
    T: Send

impl<'a, T> Sync for FixedSliceVec<'a, T> where
    T: Sync

impl<'a, T> Unpin for FixedSliceVec<'a, T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.