File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -298,6 +298,21 @@ impl<T: ?Sized> From<UniqueRef<T>> for Ref<T> {
298
298
}
299
299
}
300
300
301
+ impl < T : ?Sized > From < UniqueRef < T > > for Pin < UniqueRef < T > > {
302
+ fn from ( obj : UniqueRef < T > ) -> Self {
303
+ // SAFETY: It is not possible to move/replace `T` inside a `Pin<UniqueRef<T>>` (unless `T`
304
+ // is `Unpin`), so it is ok to convert it to `Pin<UniqueRef<T>>`.
305
+ unsafe { Pin :: new_unchecked ( obj) }
306
+ }
307
+ }
308
+
309
+ impl < T : ?Sized > From < Pin < UniqueRef < T > > > for Ref < T > {
310
+ fn from ( item : Pin < UniqueRef < T > > ) -> Self {
311
+ // SAFETY: The type invariants of `Ref` guarantee that the data is pinned.
312
+ unsafe { Pin :: into_inner_unchecked ( item) . inner }
313
+ }
314
+ }
315
+
301
316
/// A borrowed [`Ref`] with manually-managed lifetime.
302
317
///
303
318
/// # Invariants
You can’t perform that action at this time.
0 commit comments