Function gstd::prelude::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
)Expand description
Creates the asynchronous destructor of the pointed-to value.
§Safety
Behavior is undefined if any of the following conditions are violated:
-
to_drop
must be valid for both reads and writes. -
to_drop
must be properly aligned, even ifT
has size 0. -
to_drop
must be nonnull, even ifT
has size 0. -
The value
to_drop
points 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_place
is executing or the returned async destructor is alive, the only way to access parts ofto_drop
is through theself: Pin<&mut Self>
references supplied to theAsyncDrop::async_drop
methods thatasync_drop_in_place
orAsyncDropInPlace<T>::poll
invokes. This usually means the returned future stores theto_drop
pointer and user is required to guarantee that dropped value doesn’t move.