Function std::future::async_drop_in_place
source · pub unsafe fn async_drop_in_place<T>(to_drop: *mut T) -> AsyncDropInPlace<T> ⓘwhere
T: ?Sized,async_drop #126482)Expand description
Creates the asynchronous destructor of the pointed-to value.
§Safety
Behavior is undefined if any of the following conditions are violated:
-
to_dropmust be valid for both reads and writes. -
to_dropmust be properly aligned, even ifThas size 0. -
to_dropmust be nonnull, even ifThas size 0. -
The value
to_droppoints to must be valid for async dropping, which may mean it must uphold additional invariants. These invariants depend on the type of the value being dropped. For instance, when dropping a Box, the box’s pointer to the heap must be valid. -
While
async_drop_in_placeis executing or the returned async destructor is alive, the only way to access parts ofto_dropis through theself: Pin<&mut Self>references supplied to theAsyncDrop::async_dropmethods thatasync_drop_in_placeorAsyncDropInPlace<T>::pollinvokes. This usually means the returned future stores theto_droppointer and user is required to guarantee that dropped value doesn’t move.