Trait kernel::init::PinnedDrop

source ·
pub unsafe trait PinnedDrop: HasPinData {
    // Required method
    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;
struct Foo {
    mtx: Mutex<usize>,

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


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

Required Methods§


fn drop(self: Pin<&mut Self>, only_call_from_drop: OnlyCallFromDrop)

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.