mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Make Pin::new_static const.
This commit is contained in:
parent
64839ee00a
commit
390883e888
@ -787,7 +787,8 @@ impl<T: ?Sized> Pin<&'static T> {
|
|||||||
/// This is safe, because the `'static` lifetime guarantees the data will
|
/// This is safe, because the `'static` lifetime guarantees the data will
|
||||||
/// never be moved.
|
/// never be moved.
|
||||||
#[unstable(feature = "pin_static_ref", issue = "none")]
|
#[unstable(feature = "pin_static_ref", issue = "none")]
|
||||||
pub fn new_static(r: &'static T) -> Pin<&'static T> {
|
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
|
||||||
|
pub const fn new_static(r: &'static T) -> Pin<&'static T> {
|
||||||
// SAFETY: The 'static lifetime guarantees the data will not be
|
// SAFETY: The 'static lifetime guarantees the data will not be
|
||||||
// moved/invalidated until it gets dropped (which is never).
|
// moved/invalidated until it gets dropped (which is never).
|
||||||
unsafe { Pin::new_unchecked(r) }
|
unsafe { Pin::new_unchecked(r) }
|
||||||
|
Loading…
Reference in New Issue
Block a user