Function fixed_slice_vec::single::embed_uninit[][src]

pub fn embed_uninit<'a, T, F, E>(
    destination: &'a mut [MaybeUninit<u8>],
    f: F
) -> Result<&'a mut T, EmbedValueError<E>> where
    F: FnOnce(&'a mut [MaybeUninit<u8>]) -> Result<T, E>, 

Initialize a value into location within a provided byte slice, and return a mutable reference to that value.

The user-provided constructor function also has access to the portions of the byte slice after the region allocated for the embedded value itself.

Safety

Panics in debug mode if destination slice’s underlying pointer has somehow been contrived to be null.

This function does nothing to ensure that the embedded value will be dropped when the returned reference is dropped. The caller is responsible for cleaning up any side effects of the embedded value outside of the destination slice.