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 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.
  • the slot may move after initialization.
  • while constructing the T at slot it upholds the pinning invariants of T.