1 #![warn(rust_2018_idioms, single_use_lifetimes)] 2 #![allow(dead_code)] 3 4 #[macro_use] 5 mod auxiliary; 6 7 pub mod default { 8 use pin_project_lite::pin_project; 9 use std::marker::PhantomPinned; 10 11 struct Inner<T> { 12 f: T, 13 } 14 15 assert_unpin!(Inner<()>); 16 assert_not_unpin!(Inner<PhantomPinned>); 17 18 pin_project! { 19 struct Struct<T, U> { 20 #[pin] 21 f1: Inner<T>, 22 f2: U, 23 } 24 } 25 26 assert_unpin!(Struct<(), ()>); 27 assert_unpin!(Struct<(), PhantomPinned>); 28 assert_not_unpin!(Struct<PhantomPinned, ()>); 29 assert_not_unpin!(Struct<PhantomPinned, PhantomPinned>); 30 31 pin_project! { 32 #[project = EnumProj] 33 #[project_ref = EnumProjRef] 34 enum Enum<T, U> { 35 V1 { 36 #[pin] 37 f1: Inner<T>, 38 f2: U, 39 }, 40 } 41 } 42 43 assert_unpin!(Enum<(), ()>); 44 assert_unpin!(Enum<(), PhantomPinned>); 45 assert_not_unpin!(Enum<PhantomPinned, ()>); 46 assert_not_unpin!(Enum<PhantomPinned, PhantomPinned>); 47 48 pin_project! { 49 struct TrivialBounds { 50 #[pin] 51 f: PhantomPinned, 52 } 53 } 54 55 assert_not_unpin!(TrivialBounds); 56 57 pin_project! { 58 struct PinRef<'a, T, U> { 59 #[pin] 60 f1: &'a mut Inner<T>, 61 f2: U, 62 } 63 } 64 65 assert_unpin!(PinRef<'_, PhantomPinned, PhantomPinned>); 66 } 67