Function kernel::init::pin_init_from_closure
source · pub const unsafe fn pin_init_from_closure<T: ?Sized, E>(
f: impl FnOnce(*mut T) -> Result<(), E>
) -> impl PinInit<T, E>
Expand description
Creates a new PinInit<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:slot
can be deallocated without UB occurring,slot
does not need to be dropped,slot
is not partially initialized.
- may assume that the
slot
does not move ifT: !Unpin
, - while constructing the
T
atslot
it upholds the pinning invariants ofT
.