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:slotcan be deallocated without UB occurring,slotdoes not need to be dropped,slotis not partially initialized.
- may assume that the
slotdoes not move ifT: !Unpin, - while constructing the
Tatslotit upholds the pinning invariants ofT.