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 of slot,
  • returns Err(err) if it encountered an error and then cleaned slot, 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 if T: !Unpin,
  • while constructing the T at slot it upholds the pinning invariants of T.
This documentation is an old archive. Please see https://rust.docs.kernel.org instead.