Make Pin::new_static const.

This commit is contained in:
Mara Bos 2020-10-09 00:06:39 +02:00
parent 64839ee00a
commit 390883e888
1 changed files with 2 additions and 1 deletions

View File

@ -787,7 +787,8 @@ impl<T: ?Sized> Pin<&'static T> {
/// This is safe, because the `'static` lifetime guarantees the data will
/// never be moved.
#[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
// moved/invalidated until it gets dropped (which is never).
unsafe { Pin::new_unchecked(r) }