pub unsafe trait InitializeVectored {
type UninitVector: Initialize;
// Required methods
fn as_maybe_uninit_vectors(&self) -> &[Self::UninitVector];
unsafe fn as_maybe_uninit_vectors_mut(
&mut self,
) -> &mut [Self::UninitVector];
}
Expand description
A trait for slices (or owned memory) that contain possibly uninitialized slices themselves.
That is, the Initialize
trait but for singly-indirect slices.
§Safety
For this trait to be implemented correctly, as_maybe_uninit_vectors
and
as_maybe_uninit_vectors_mut
must always return the same slices (albeit with different
aliasing rules as they take &self
and &mut self
respectively).
Required Associated Types§
Sourcetype UninitVector: Initialize
type UninitVector: Initialize
The possibly uninitialized vector type, which must implement Initialize
. Note that this
does not necessarily need to deref into MaybeUninit<Item>
, but can be anything that is
convertible to it.
Required Methods§
Sourcefn as_maybe_uninit_vectors(&self) -> &[Self::UninitVector]
fn as_maybe_uninit_vectors(&self) -> &[Self::UninitVector]
Get the uninitialized version of all vectors. This slice must always be exactly equal to
the slice returned by
as_maybe_uninit_vectors_mut
, except
being borrowed differently, or the trait is unsoundly implemented.
Sourceunsafe fn as_maybe_uninit_vectors_mut(&mut self) -> &mut [Self::UninitVector]
unsafe fn as_maybe_uninit_vectors_mut(&mut self) -> &mut [Self::UninitVector]
Get the uninitialized version of all vectors, mutably. This slice must always be exactly
equal to the slice returned by as_maybe_uninit_vectors
,
or the trait is unsoundly implemented.
§Safety
For the user of this trait, the resulting slice returned from this method must not be
used to de-initialize the vectors by overwriting their contents with
MaybeUninit::uninit
if they were already initialized.