Function kernel::init::init_from_closure  
source · [−]pub const unsafe fn init_from_closure<T: ?Sized, E>(
    f: impl FnOnce(*mut T) -> Result<(), E>
) -> impl Init<T, E>Expand description
Creates a new Init<T, E> from the given closure.
Safety
The closure:
- returns 
Ok(())if it initialized every field ofslot, - returns 
Err(err)if it encountered an error and then cleanedslot, this means:slotcan be deallocated without UB occurring,slotdoes not need to be dropped,slotis not partially initialized.
 - the 
slotmay move after initialization. - while constructing the 
Tatslotit upholds the pinning invariants ofT.