From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- vendor/pin-utils/tests/projection.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 vendor/pin-utils/tests/projection.rs (limited to 'vendor/pin-utils/tests/projection.rs') diff --git a/vendor/pin-utils/tests/projection.rs b/vendor/pin-utils/tests/projection.rs new file mode 100644 index 000000000..492c26d9a --- /dev/null +++ b/vendor/pin-utils/tests/projection.rs @@ -0,0 +1,27 @@ +use pin_utils::{unsafe_pinned, unsafe_unpinned, pin_mut}; +use std::pin::Pin; +use std::marker::Unpin; + +struct Foo { + field1: T1, + field2: T2, +} + +impl Foo { + unsafe_pinned!(field1: T1); + unsafe_unpinned!(field2: T2); +} + +impl Unpin for Foo {} // Conditional Unpin impl + +#[test] +fn projection() { + let foo = Foo { field1: 1, field2: 2 }; + pin_mut!(foo); + + let x1: Pin<&mut i32> = foo.as_mut().field1(); + assert_eq!(*x1, 1); + + let x2: &mut i32 = foo.as_mut().field2(); + assert_eq!(*x2, 2); +} -- cgit v1.2.3