1 // SPDX-License-Identifier: Apache-2.0 OR MIT 2 3 // default #[pin_project], PinnedDrop, project_replace, !Unpin, and UnsafeUnpin without UnsafeUnpin impl are completely safe. 4 5 /// Testing default struct. 6 #[allow(clippy::exhaustive_structs)] // for the type itself 7 #[::pin_project::pin_project] 8 #[derive(Debug)] 9 pub struct DefaultStruct<T, U> { 10 /// Pinned field. 11 #[pin] 12 pub pinned: T, 13 /// Unpinned field. 14 pub unpinned: U, 15 } 16 17 /// Testing named struct. 18 #[::pin_project::pin_project( 19 project = DefaultStructNamedProj, 20 project_ref = DefaultStructNamedProjRef, 21 )] 22 #[derive(Debug)] 23 #[allow(clippy::exhaustive_structs)] // for the type itself 24 pub struct DefaultStructNamed<T, U> { 25 /// Pinned field. 26 #[pin] 27 pub pinned: T, 28 /// Unpinned field. 29 pub unpinned: U, 30 } 31 32 /// Testing default tuple struct. 33 #[::pin_project::pin_project] 34 #[allow(clippy::exhaustive_structs)] // for the type itself 35 #[derive(Debug)] 36 pub struct DefaultTupleStruct<T, U>(#[pin] pub T, pub U); 37 38 /// Testing named tuple struct. 39 #[::pin_project::pin_project( 40 project = DefaultTupleStructNamedProj, 41 project_ref = DefaultTupleStructNamedProjRef, 42 )] 43 #[allow(clippy::exhaustive_structs)] // for the type itself 44 #[derive(Debug)] 45 pub struct DefaultTupleStructNamed<T, U>(#[pin] pub T, pub U); 46 47 /// Testing enum. 48 #[allow(clippy::exhaustive_enums)] // for the type itself 49 #[::pin_project::pin_project( 50 project = DefaultEnumProj, 51 project_ref = DefaultEnumProjRef, 52 )] 53 #[derive(Debug)] 54 pub enum DefaultEnum<T, U> { 55 /// Struct variant. 56 Struct { 57 /// Pinned field. 58 #[pin] 59 pinned: T, 60 /// Unpinned field. 61 unpinned: U, 62 }, 63 /// Tuple variant. 64 Tuple(#[pin] T, U), 65 /// Unit variant. 66 Unit, 67 } 68 69 /// Testing pinned drop struct. 70 #[allow(clippy::exhaustive_structs)] // for the type itself 71 #[::pin_project::pin_project(PinnedDrop)] 72 #[derive(Debug)] 73 pub struct PinnedDropStruct<T, U> { 74 /// Pinned field. 75 #[pin] 76 pub pinned: T, 77 /// Unpinned field. 78 pub unpinned: U, 79 } 80 81 #[::pin_project::pinned_drop] 82 impl<T, U> PinnedDrop for PinnedDropStruct<T, U> { 83 #[allow(clippy::absolute_paths)] drop(self: ::pin_project::__private::Pin<&mut Self>)84 fn drop(self: ::pin_project::__private::Pin<&mut Self>) {} 85 } 86 87 /// Testing pinned drop tuple struct. 88 #[allow(clippy::exhaustive_structs)] // for the type itself 89 #[::pin_project::pin_project(PinnedDrop)] 90 #[derive(Debug)] 91 pub struct PinnedDropTupleStruct<T, U>(#[pin] pub T, pub U); 92 93 #[::pin_project::pinned_drop] 94 impl<T, U> PinnedDrop for PinnedDropTupleStruct<T, U> { 95 #[allow(clippy::absolute_paths)] drop(self: ::pin_project::__private::Pin<&mut Self>)96 fn drop(self: ::pin_project::__private::Pin<&mut Self>) {} 97 } 98 99 /// Testing pinned drop enum. 100 #[allow(clippy::absolute_paths, clippy::exhaustive_enums)] // for the type itself 101 #[::pin_project::pin_project( 102 PinnedDrop, 103 project = PinnedDropEnumProj, 104 project_ref = PinnedDropEnumProjRef, 105 )] 106 #[derive(Debug)] 107 pub enum PinnedDropEnum<T: ::pin_project::__private::Unpin, U> { 108 /// Struct variant. 109 Struct { 110 /// Pinned field. 111 #[pin] 112 pinned: T, 113 /// Unpinned field. 114 unpinned: U, 115 }, 116 /// Tuple variant. 117 Tuple(#[pin] T, U), 118 /// Unit variant. 119 Unit, 120 } 121 122 #[::pin_project::pinned_drop] 123 #[allow(clippy::absolute_paths)] 124 impl<T: ::pin_project::__private::Unpin, U> PinnedDrop for PinnedDropEnum<T, U> { drop(self: ::pin_project::__private::Pin<&mut Self>)125 fn drop(self: ::pin_project::__private::Pin<&mut Self>) {} 126 } 127 128 /// Testing default struct with replace. 129 #[allow(clippy::exhaustive_structs)] // for the type itself 130 #[::pin_project::pin_project(project_replace)] 131 #[derive(Debug)] 132 pub struct ReplaceStruct<T, U> { 133 /// Pinned field. 134 #[pin] 135 pub pinned: T, 136 /// Unpinned field. 137 pub unpinned: U, 138 } 139 140 /// Testing named struct with replace. 141 #[::pin_project::pin_project( 142 project = ReplaceStructNamedProj, 143 project_ref = ReplaceStructNamedProjRef, 144 project_replace = ReplaceStructNamedProjOwn, 145 )] 146 #[allow(clippy::exhaustive_structs)] // for the type itself 147 #[derive(Debug)] 148 pub struct ReplaceStructNamed<T, U> { 149 /// Pinned field. 150 #[pin] 151 pub pinned: T, 152 /// Unpinned field. 153 pub unpinned: U, 154 } 155 156 /// Testing default struct with replace. 157 #[::pin_project::pin_project(project_replace)] 158 #[derive(Debug)] 159 #[allow(clippy::exhaustive_structs)] // for the type itself 160 pub struct ReplaceTupleStruct<T, U>(#[pin] pub T, pub U); 161 162 /// Testing named struct with replace. 163 #[::pin_project::pin_project( 164 project = ReplaceTupleStructNamedProj, 165 project_ref = ReplaceTupleStructNamedProjRef, 166 project_replace = ReplaceTupleStructNamedProjOwn, 167 )] 168 #[derive(Debug)] 169 #[allow(clippy::exhaustive_structs)] // for the type itself 170 pub struct ReplaceTupleStructNamed<T, U>(#[pin] pub T, pub U); 171 172 /// Testing enum with replace. 173 #[allow(clippy::exhaustive_enums)] // for the type itself 174 #[::pin_project::pin_project( 175 project = ReplaceEnumProj, 176 project_ref = ReplaceEnumProjRef, 177 project_replace = ReplaceEnumProjOwn, 178 )] 179 #[derive(Debug)] 180 pub enum ReplaceEnum<T, U> { 181 /// Struct variant. 182 Struct { 183 /// Pinned field. 184 #[pin] 185 pinned: T, 186 /// Unpinned field. 187 unpinned: U, 188 }, 189 /// Tuple variant. 190 Tuple(#[pin] T, U), 191 /// Unit variant. 192 Unit, 193 } 194 195 /// Testing struct with unsafe `Unpin`. 196 #[::pin_project::pin_project(UnsafeUnpin)] 197 #[allow(clippy::exhaustive_structs)] // for the type itself 198 #[derive(Debug)] 199 pub struct UnsafeUnpinStruct<T, U> { 200 /// Pinned field. 201 #[pin] 202 pub pinned: T, 203 /// Unpinned field. 204 pub unpinned: U, 205 } 206 207 /// Testing tuple struct with unsafe `Unpin`. 208 #[::pin_project::pin_project(UnsafeUnpin)] 209 #[allow(clippy::exhaustive_structs)] // for the type itself 210 #[derive(Debug)] 211 pub struct UnsafeUnpinTupleStruct<T, U>(#[pin] pub T, pub U); 212 213 /// Testing enum unsafe `Unpin`. 214 #[allow(clippy::exhaustive_enums)] // for the type itself 215 #[::pin_project::pin_project( 216 UnsafeUnpin, 217 project = UnsafeUnpinEnumProj, 218 project_ref = UnsafeUnpinEnumProjRef, 219 )] 220 #[derive(Debug)] 221 pub enum UnsafeUnpinEnum<T, U> { 222 /// Struct variant. 223 Struct { 224 /// Pinned field. 225 #[pin] 226 pinned: T, 227 /// Unpinned field. 228 unpinned: U, 229 }, 230 /// Tuple variant. 231 Tuple(#[pin] T, U), 232 /// Unit variant. 233 Unit, 234 } 235 236 /// Testing struct with `!Unpin`. 237 #[::pin_project::pin_project(!Unpin)] 238 #[derive(Debug)] 239 #[allow(clippy::exhaustive_structs)] // for the type itself 240 pub struct NotUnpinStruct<T, U> { 241 /// Pinned field. 242 #[pin] 243 pub pinned: T, 244 /// Unpinned field. 245 pub unpinned: U, 246 } 247 248 /// Testing tuple struct with `!Unpin`. 249 #[allow(clippy::exhaustive_structs)] // for the type itself 250 #[::pin_project::pin_project(!Unpin)] 251 #[derive(Debug)] 252 pub struct NotUnpinTupleStruct<T, U>(#[pin] pub T, pub U); 253 254 /// Testing enum with `!Unpin`. 255 #[allow(clippy::exhaustive_enums)] // for the type itself 256 #[::pin_project::pin_project( 257 !Unpin, 258 project = NotUnpinEnumProj, 259 project_ref = NotUnpinEnumProjRef, 260 )] 261 #[derive(Debug)] 262 pub enum NotUnpinEnum<T, U> { 263 /// Struct variant. 264 Struct { 265 /// Pinned field. 266 #[pin] 267 pinned: T, 268 /// Unpinned field. 269 unpinned: U, 270 }, 271 /// Tuple variant. 272 Tuple(#[pin] T, U), 273 /// Unit variant. 274 Unit, 275 } 276