Initialize

Trait Initialize 

Source
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§

Source

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.

Source

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.

Implementations on Foreign Types§

Source§

impl<'a, T> Initialize for &'a mut [MaybeUninit<T>]

Source§

type Item = T

Source§

fn as_maybe_uninit_slice(&self) -> &[MaybeUninit<T>]

Source§

unsafe fn as_maybe_uninit_slice_mut(&mut self) -> &mut [MaybeUninit<T>]

Source§

impl<T> Initialize for Box<[MaybeUninit<T>]>

Source§

type Item = T

Source§

fn as_maybe_uninit_slice(&self) -> &[MaybeUninit<T>]

Source§

unsafe fn as_maybe_uninit_slice_mut(&mut self) -> &mut [MaybeUninit<T>]

Source§

impl<T, const N: usize> Initialize for [MaybeUninit<T>; N]

Source§

type Item = T

Source§

fn as_maybe_uninit_slice(&self) -> &[MaybeUninit<T>]

Source§

unsafe fn as_maybe_uninit_slice_mut(&mut self) -> &mut [MaybeUninit<T>]

Implementors§

Source§

impl<T, Item> Initialize for AsUninit<T>
where T: Deref<Target = [Item]> + DerefMut + TrustedDeref,

Source§

type Item = Item

Source§

impl<T: Initialize> Initialize for SingleVector<T>