File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -795,6 +795,20 @@ impl<T: ?Sized> Pin<&'static T> {
795795 }
796796}
797797
798+ impl < T : ?Sized > Pin < & ' static T > {
799+ /// Get a pinned mutable reference from a static mutable reference.
800+ ///
801+ /// This is safe, because the `'static` lifetime guarantees the data will
802+ /// never be moved.
803+ #[ unstable( feature = "pin_static_ref" , issue = "none" ) ]
804+ #[ rustc_const_unstable( feature = "const_pin" , issue = "76654" ) ]
805+ pub const fn static_mut ( r : & ' static mut T ) -> Pin < & ' static mut T > {
806+ // SAFETY: The 'static lifetime guarantees the data will not be
807+ // moved/invalidated until it gets dropped (which is never).
808+ unsafe { Pin :: new_unchecked ( r) }
809+ }
810+ }
811+
798812#[ stable( feature = "pin" , since = "1.33.0" ) ]
799813impl < P : Deref > Deref for Pin < P > {
800814 type Target = P :: Target ;
You can’t perform that action at this time.
0 commit comments