summaryrefslogtreecommitdiff
path: root/vendor/pin-project-lite/tests/include/basic.rs
blob: 5c7308a1e27f91664e5fbb5465cb0f9695637791 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// SPDX-License-Identifier: Apache-2.0 OR MIT

// default pin_project! is completely safe.

::pin_project_lite::pin_project! {
    /// Testing default struct.
    #[derive(Debug)]
    #[allow(clippy::exhaustive_structs)] // for the type itself
    pub struct DefaultStruct<T, U> {
        #[pin]
        pub pinned: T,
        pub unpinned: U,
    }
}

::pin_project_lite::pin_project! {
    /// Testing named struct.
    #[allow(clippy::exhaustive_structs)] // for the type itself
    #[project = DefaultStructProj]
    #[project_ref = DefaultStructProjRef]
    #[derive(Debug)]
    pub struct DefaultStructNamed<T, U> {
        #[pin]
        pub pinned: T,
        pub unpinned: U,
    }
}

::pin_project_lite::pin_project! {
    /// Testing enum.
    #[allow(clippy::exhaustive_enums)] // for the type itself
    #[project = DefaultEnumProj]
    #[project_ref = DefaultEnumProjRef]
    #[derive(Debug)]
    pub enum DefaultEnum<T, U> {
        /// Struct variant.
        Struct {
            #[pin]
            pinned: T,
            unpinned: U,
        },
        /// Unit variant.
        Unit,
    }
}

::pin_project_lite::pin_project! {
    /// Testing pinned drop struct.
    #[allow(clippy::exhaustive_structs)] // for the type itself
    #[derive(Debug)]
    pub struct PinnedDropStruct<T, U> {
        #[pin]
        pub pinned: T,
        pub unpinned: U,
    }
    impl<T, U> PinnedDrop for PinnedDropStruct<T, U> {
        fn drop(_this: Pin<&mut Self>) {}
    }
}

::pin_project_lite::pin_project! {
    /// Testing pinned drop enum.
    #[allow(clippy::absolute_paths, clippy::exhaustive_enums)] // for the type itself
    #[project = PinnedDropEnumProj]
    #[project_ref = PinnedDropEnumProjRef]
    #[derive(Debug)]
    pub enum PinnedDropEnum<T: ::pin_project_lite::__private::Unpin, U> {
        /// Struct variant.
        Struct {
            #[pin]
            pinned: T,
            unpinned: U,
        },
        /// Unit variant.
        Unit,
    }
    #[allow(clippy::absolute_paths)]
    impl<T: ::pin_project_lite::__private::Unpin, U> PinnedDrop for PinnedDropEnum<T, U> {
        fn drop(_this: Pin<&mut Self>) {}
    }
}