summaryrefslogtreecommitdiffstats
path: root/third_party/rust/pin-project/examples/pinned_drop.rs
blob: 6fb87193f626ce58c4ab5a68ce2863473dfb1ef9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// See ./pinned_drop-expanded.rs for generated code.

#![allow(dead_code)]

use std::pin::Pin;

use pin_project::{pin_project, pinned_drop};

#[pin_project(PinnedDrop)]
pub struct Struct<'a, T> {
    was_dropped: &'a mut bool,
    #[pin]
    field: T,
}

#[pinned_drop]
impl<T> PinnedDrop for Struct<'_, T> {
    fn drop(self: Pin<&mut Self>) {
        **self.project().was_dropped = true;
    }
}

fn main() {}