Skip to main content

SliceMut

Type Alias SliceMut 

Source
pub type SliceMut<'a, T, M> = Slice<&'a mut [T], Mut<'a, M>>;
Expand description

A mutable reference to a slice and associated metadata.

Aliased Type§

pub struct SliceMut<'a, T, M> { /* private fields */ }

Implementations§

Source§

impl<'a, T, M> SliceMut<'a, T, M>
where T: Pod, M: Pod,

Source

pub fn from_canonical_mut( data: &'a mut [u8], dim: usize, ) -> Result<Self, NotCanonical>

Construct an instance of Self viewing data as the canonical layout for a vector. The canonical layout is as follows:

  • std::mem::size_of::<T>().max(std::mem::size_of::<M>()) for the metadata.
  • Necessary additional padding to achieve the alignment requirements for T.
  • std::mem::size_of::<T>() * dim for the slice.

Returns an error if:

  • data is not aligned to Self::canonical_align().
  • data.len() != Self::canonical_bytes(dim)`.