pub unsafe trait PinnedDrop: HasPinData {
    fn drop(self: Pin<&mut Self>, only_call_from_drop: OnlyCallFromDrop);
}
Expand description

Trait facilitating pinned destruction.

Use pinned_drop to implement this trait safely:

use kernel::macros::pinned_drop;
use core::pin::Pin;
#[pin_data(PinnedDrop)]
struct Foo {
    #[pin]
    mtx: Mutex<usize>,
}

#[pinned_drop]
impl PinnedDrop for Foo {
    fn drop(self: Pin<&mut Self>) {
        pr_info!("Foo is being dropped!");
    }
}

Safety

This trait must be implemented via the pinned_drop proc-macro attribute on the impl.

Required Methods

Executes the pinned destructor of this type.

While this function is marked safe, it is actually unsafe to call it manually. For this reason it takes an additional parameter. This type can only be constructed by unsafe code and thus prevents this function from being called where it should not.

This extra parameter will be generated by the #[pinned_drop] proc-macro attribute automatically.

Implementors