pub unsafe trait Initialize {
type Item;
// Required methods
fn as_maybe_uninit_slice(&self) -> &[MaybeUninit<Self::Item>];
unsafe fn as_maybe_uninit_slice_mut(
&mut self,
) -> &mut [MaybeUninit<Self::Item>];
}
Expand description
A trait for mutable initializable slices, that provide access to all the data required for initialization, before the data can be assumed to be fully initialized.
§Safety
This trait is unsafe to implement since whatever slices are returned from the casts here, must have the same length and point to the same memory as before. This is to allow safer abstractions to assume that there are has not unexpectedly appeared additional items that must be initialized.
Required Associated Types§
Required Methods§
Sourcefn as_maybe_uninit_slice(&self) -> &[MaybeUninit<Self::Item>]
fn as_maybe_uninit_slice(&self) -> &[MaybeUninit<Self::Item>]
Retrieve an immutable slice pointing to possibly uninitialized memory. This must be
exactly the same slice as the one from as_maybe_uninit_slice_mut
, or the trait
implementation as a whole, gets incorrect.
Sourceunsafe fn as_maybe_uninit_slice_mut(&mut self) -> &mut [MaybeUninit<Self::Item>]
unsafe fn as_maybe_uninit_slice_mut(&mut self) -> &mut [MaybeUninit<Self::Item>]
Retrieve a mutable slice pointing to possibly uninitialized memory. This must always point to the same slice as with previous invocations.
§Safety
The caller must not use the resulting slice to de-initialize the data.