pub unsafe trait PinInit<T, E = Infallible>: Sized {
    unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E>;
}
Expand description

A pinned initializer for T.

To use this initializer, you will need a suitable memory location that can hold a T. This can be Box<T>, Arc<T>, or even the stack (see stack_init!). Use the pin_init function of a smart pointer like Arc::pin_init on this.

Also see the module description.

Safety

When implementing this type you will need to take great care. Also there are probably very few cases where a manual implementation is necessary. Use from_value and pin_init_from_closure where possible.

The PinInit::__pinned_init function

  • returns Ok(()) iff it initialized every field of slot,
  • returns Err(err) iff it encountered an error and then cleaned slot, this means:
    • slot can be deallocated without UB ocurring,
    • slot does not need to be dropped,
    • slot is not partially initialized.

Required Methods

Initializes slot.

Safety

slot is a valid pointer to uninitialized memory. The caller does not touch slot when Err is returned, they are only permitted to deallocate. The slot will not move, i.e. it will be pinned.

Implementors