Attribute Macro macros::pinned_drop

source ·
#[pinned_drop]
Expand description

Used to implement PinnedDrop safely.

Only works on structs that are annotated via #[pin_data].

Examples

#[pin_data(PinnedDrop)]
struct DriverData {
    #[pin]
    queue: Mutex<Vec<Command>>,
    buf: Box<[u8; 1024 * 1024]>,
    raw_info: *mut Info,
}

#[pinned_drop]
impl PinnedDrop for DriverData {
    fn drop(self: Pin<&mut Self>) {
        unsafe { bindings::destroy_info(self.raw_info) };
    }
}
This documentation is an old archive. Please see https://rust.docs.kernel.org instead.