We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 93ba97f commit 956238eCopy full SHA for 956238e
library/core/src/pin.rs
@@ -781,6 +781,19 @@ impl<'a, T: ?Sized> Pin<&'a mut T> {
781
}
782
783
784
+impl<T: ?Sized> Pin<&'static T> {
785
+ /// Get a pinned reference from a static reference.
786
+ ///
787
+ /// This is safe, because the `'static` lifetime guarantees the data will
788
+ /// never be moved.
789
+ #[unstable(feature = "pin_static_ref", issue = "none")]
790
+ pub fn new_static(r: &'static T) -> Pin<&'static T> {
791
+ // SAFETY: The 'static lifetime guarantees the data will not be
792
+ // moved/invalidated until it gets dropped (which is never).
793
+ unsafe { Pin::new_unchecked(r) }
794
+ }
795
+}
796
+
797
#[stable(feature = "pin", since = "1.33.0")]
798
impl<P: Deref> Deref for Pin<P> {
799
type Target = P::Target;
0 commit comments