Skip to main content

DropHusk

Trait DropHusk 

Source
pub unsafe trait DropHusk: PlaceProxy {
    // Required method
    unsafe fn drop_husk(this: *mut Self);
}
Expand description

Destroy a PlaceProxy where its contents have been moved out/dropped.

This is essentially like Drop, but supports the situation where the value stored in the place represented by Self have been moved out, dropped, or never initialized to begin with.

The borrow checker tracks the initialization state of each (sub)place. When a PlaceProxy supports moving values out (i.e. when its handle implements MovePlace), then after moving out the entire value, the allocation might still be live. Since the value is no longer populated, calling Drop::drop as normal would result in using a moved-out value, which can result in a double-free.

Instead, this trait is combined with DropPlace, which the compiler uses to drop any not-moved-out subplaces and then drops the allocation (or any other data that the proxy had) through this trait.

Required Methods§

Source

unsafe fn drop_husk(this: *mut Self)

Destroy the proxy associated with the place of this.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<P> DropHusk for Pin<P>
where P: DropHusk,

Source§

unsafe fn drop_husk(this: *mut Self)

Source§

impl<T: ?Sized> DropHusk for Box<T>

Source§

unsafe fn drop_husk(this: *mut Self)

Source§

impl<T> DropHusk for *mut T

Source§

unsafe fn drop_husk(_: *mut Self)

Implementors§