mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-15 08:23:26 +00:00
Add Pin::static_mut.
This commit is contained in:
parent
104c0f0194
commit
2c71f682d7
@ -795,6 +795,20 @@ impl<T: ?Sized> Pin<&'static T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: ?Sized> Pin<&'static T> {
|
||||
/// Get a pinned mutable reference from a static mutable reference.
|
||||
///
|
||||
/// This is safe, because the `'static` lifetime guarantees the data will
|
||||
/// never be moved.
|
||||
#[unstable(feature = "pin_static_ref", issue = "none")]
|
||||
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
|
||||
pub const fn static_mut(r: &'static mut T) -> Pin<&'static mut 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) }
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "pin", since = "1.33.0")]
|
||||
impl<P: Deref> Deref for Pin<P> {
|
||||
type Target = P::Target;
|
||||
|
Loading…
Reference in New Issue
Block a user