5 // test that the methods of `Pin` are usable in a const context
7 const POINTER
: &'
static usize = &2;
9 const PINNED
: Pin
<&'
static usize> = Pin
::new(POINTER
);
10 const PINNED_UNCHECKED
: Pin
<&'
static usize> = unsafe { Pin::new_unchecked(POINTER) }
;
11 assert_eq
!(PINNED_UNCHECKED
, PINNED
);
13 const INNER
: &'
static usize = Pin
::into_inner(PINNED
);
14 assert_eq
!(INNER
, POINTER
);
16 const INNER_UNCHECKED
: &'
static usize = unsafe { Pin::into_inner_unchecked(PINNED) }
;
17 assert_eq
!(INNER_UNCHECKED
, POINTER
);
19 const REF
: &'
static usize = PINNED
.get_ref();
20 assert_eq
!(REF
, POINTER
);
22 // Note: `pin_mut_const` tests that the methods of `Pin<&mut T>` are usable in a const context.
23 // A const fn is used because `&mut` is not (yet) usable in constants.
24 const fn pin_mut_const() {
25 let _
= Pin
::new(&mut 2).into_ref();
26 let _
= Pin
::new(&mut 2).get_mut();
27 let _
= unsafe { Pin::new(&mut 2).get_unchecked_mut() }
;