File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -177,6 +177,24 @@ impl<T: ?Sized> SyncView<T> {
177177 }
178178}
179179
180+ impl < T : ?Sized + Sync > SyncView < T > {
181+ /// Gets pinned shared access to the underlying value.
182+ ///
183+ /// `SyncView` is considered to _structurally pin_ the underlying
184+ /// value, which means _unpinned_ `SyncView`s can produce _unpinned_
185+ /// access to the underlying value, but _pinned_ `SyncView`s only
186+ /// produce _pinned_ access to the underlying value.
187+ #[ unstable( feature = "exclusive_wrapper" , issue = "98407" ) ]
188+ #[ rustc_const_unstable( feature = "exclusive_wrapper" , issue = "98407" ) ]
189+ #[ must_use]
190+ #[ inline]
191+ pub const fn as_pin ( self : Pin < & Self > ) -> Pin < & T > {
192+ // SAFETY: `SyncView` can only produce `&T` if itself is unpinned
193+ // `Pin::map_unchecked` is not const, so we do this conversion manually
194+ unsafe { Pin :: new_unchecked ( & self . get_ref ( ) . inner ) }
195+ }
196+ }
197+
180198#[ unstable( feature = "exclusive_wrapper" , issue = "98407" ) ]
181199#[ rustc_const_unstable( feature = "const_convert" , issue = "143773" ) ]
182200impl < T > const From < T > for SyncView < T > {
You can’t perform that action at this time.
0 commit comments