[][src]Attribute Macro pin_project_internal::pinned_drop

#[pinned_drop]

An attribute for annotating a function that implements Drop.

This attribute is only needed when you wish to provide a Drop impl for your type. The function annotated with #[pinned_drop] acts just like a normal drop impl, except for the fact that it takes Pin<&mut Self>. In particular, it will never be called more than once, just like Drop::drop.

Example

use pin_project::{pin_project, pinned_drop};
use std::pin::Pin;

#[pin_project(PinnedDrop)]
struct Foo {
    #[pin] field: u8
}

#[pinned_drop]
fn my_drop(foo: Pin<&mut Foo>) {
    println!("Dropping: {}", foo.field);
}

fn main() {
    Foo { field: 50 };
}

See "pinned-drop" section of pin_project attribute for more.