forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make some methods of
Pin
unstable const
Make the following methods unstable const under the `const_pin` feature: - `new` - `new_unchecked` - `into_inner` - `into_inner_unchecked` - `get_ref` - `into_ref` Also adds tests for these methods in a const context. Tracking issue: rust-lang#76654
- Loading branch information
Showing
4 changed files
with
40 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use core::pin::Pin; | ||
|
||
#[test] | ||
fn pin_const() { | ||
// test that the methods of `Pin` are usable in a const context | ||
|
||
const POINTER: &'static usize = &2; | ||
|
||
const PINNED: Pin<&'static usize> = Pin::new(POINTER); | ||
const PINNED_UNCHECKED: Pin<&'static usize> = unsafe { Pin::new_unchecked(POINTER) }; | ||
assert_eq!(PINNED_UNCHECKED, PINNED); | ||
|
||
const INNER: &'static usize = Pin::into_inner(PINNED); | ||
assert_eq!(INNER, POINTER); | ||
|
||
const INNER_UNCHECKED: &'static usize = unsafe { Pin::into_inner_unchecked(PINNED) }; | ||
assert_eq!(INNER_UNCHECKED, POINTER); | ||
|
||
const REF: &'static usize = PINNED.get_ref(); | ||
assert_eq!(REF, POINTER) | ||
} |