Function fixed_slice_vec::single::embed [−][src]
pub unsafe fn embed<'a, T, F, E>(
destination: &'a mut [u8],
f: F
) -> Result<&'a mut T, EmbedValueError<E>> where
F: FnOnce(&'a mut [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.
If the item type T
contains any padding bytes
then those padding bytes may be observable in the provided slice
after the reference is dropped. Observing padding bytes is
undefined behavior.