summaryrefslogtreecommitdiffstats
path: root/third_party/rust/pin-project/tests/include/basic-safe-part.rs
blob: 0b7c43e8737259c82a87d4b38329f1bf51d31ca4 (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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
// default #[pin_project], PinnedDrop, project_replace, !Unpin, and UnsafeUnpin without UnsafeUnpin impl are completely safe.

#[::pin_project::pin_project]
#[derive(Debug)]
pub struct DefaultStruct<T, U> {
    #[pin]
    pub pinned: T,
    pub unpinned: U,
}

#[::pin_project::pin_project(
    project = DefaultStructNamedProj,
    project_ref = DefaultStructNamedProjRef,
)]
#[derive(Debug)]
pub struct DefaultStructNamed<T, U> {
    #[pin]
    pub pinned: T,
    pub unpinned: U,
}

#[::pin_project::pin_project]
#[derive(Debug)]
pub struct DefaultTupleStruct<T, U>(#[pin] pub T, pub U);

#[::pin_project::pin_project(
    project = DefaultTupleStructNamedProj,
    project_ref = DefaultTupleStructNamedProjRef,
)]
#[derive(Debug)]
pub struct DefaultTupleStructNamed<T, U>(#[pin] pub T, pub U);

#[::pin_project::pin_project(
    project = DefaultEnumProj,
    project_ref = DefaultEnumProjRef,
)]
#[derive(Debug)]
pub enum DefaultEnum<T, U> {
    Struct {
        #[pin]
        pinned: T,
        unpinned: U,
    },
    Tuple(#[pin] T, U),
    Unit,
}

#[::pin_project::pin_project(PinnedDrop)]
#[derive(Debug)]
pub struct PinnedDropStruct<T, U> {
    #[pin]
    pub pinned: T,
    pub unpinned: U,
}

#[::pin_project::pinned_drop]
impl<T, U> PinnedDrop for PinnedDropStruct<T, U> {
    fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
}

#[::pin_project::pin_project(PinnedDrop)]
#[derive(Debug)]
pub struct PinnedDropTupleStruct<T, U>(#[pin] pub T, pub U);

#[::pin_project::pinned_drop]
impl<T, U> PinnedDrop for PinnedDropTupleStruct<T, U> {
    fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
}

#[::pin_project::pin_project(
    PinnedDrop,
    project = PinnedDropEnumProj,
    project_ref = PinnedDropEnumProjRef,
)]
#[derive(Debug)]
pub enum PinnedDropEnum<T, U> {
    Struct {
        #[pin]
        pinned: T,
        unpinned: U,
    },
    Tuple(#[pin] T, U),
    Unit,
}

#[::pin_project::pinned_drop]
impl<T, U> PinnedDrop for PinnedDropEnum<T, U> {
    fn drop(self: ::pin_project::__private::Pin<&mut Self>) {}
}

#[::pin_project::pin_project(project_replace)]
#[derive(Debug)]
pub struct ReplaceStruct<T, U> {
    #[pin]
    pub pinned: T,
    pub unpinned: U,
}

#[::pin_project::pin_project(
    project = ReplaceStructNamedProj,
    project_ref = ReplaceStructNamedProjRef,
    project_replace = ReplaceStructNamedProjOwn,
)]
#[derive(Debug)]
pub struct ReplaceStructNamed<T, U> {
    #[pin]
    pub pinned: T,
    pub unpinned: U,
}

#[::pin_project::pin_project(project_replace)]
#[derive(Debug)]
pub struct ReplaceTupleStruct<T, U>(#[pin] pub T, pub U);

#[::pin_project::pin_project(
    project = ReplaceTupleStructNamedProj,
    project_ref = ReplaceTupleStructNamedProjRef,
    project_replace = ReplaceTupleStructNamedProjOwn,
)]
#[derive(Debug)]
pub struct ReplaceTupleStructNamed<T, U>(#[pin] pub T, pub U);

#[::pin_project::pin_project(
    project = ReplaceEnumProj,
    project_ref = ReplaceEnumProjRef,
    project_replace = ReplaceEnumProjOwn,
)]
#[derive(Debug)]
pub enum ReplaceEnum<T, U> {
    Struct {
        #[pin]
        pinned: T,
        unpinned: U,
    },
    Tuple(#[pin] T, U),
    Unit,
}

#[::pin_project::pin_project(UnsafeUnpin)]
#[derive(Debug)]
pub struct UnsafeUnpinStruct<T, U> {
    #[pin]
    pub pinned: T,
    pub unpinned: U,
}

#[::pin_project::pin_project(UnsafeUnpin)]
#[derive(Debug)]
pub struct UnsafeUnpinTupleStruct<T, U>(#[pin] pub T, pub U);

#[::pin_project::pin_project(
    UnsafeUnpin,
    project = UnsafeUnpinEnumProj,
    project_ref = UnsafeUnpinEnumProjRef,
)]
#[derive(Debug)]
pub enum UnsafeUnpinEnum<T, U> {
    Struct {
        #[pin]
        pinned: T,
        unpinned: U,
    },
    Tuple(#[pin] T, U),
    Unit,
}

#[::pin_project::pin_project(!Unpin)]
#[derive(Debug)]
pub struct NotUnpinStruct<T, U> {
    #[pin]
    pub pinned: T,
    pub unpinned: U,
}

#[::pin_project::pin_project(!Unpin)]
#[derive(Debug)]
pub struct NotUnpinTupleStruct<T, U>(#[pin] pub T, pub U);

#[::pin_project::pin_project(
    !Unpin,
    project = NotUnpinEnumProj,
    project_ref = NotUnpinEnumProjRef,
)]
#[derive(Debug)]
pub enum NotUnpinEnum<T, U> {
    Struct {
        #[pin]
        pinned: T,
        unpinned: U,
    },
    Tuple(#[pin] T, U),
    Unit,
}