Skip to content

Commit 1eec5b3

Browse files
committed
Also modify DispatchFromDyn for Pin
1 parent 7f4e36b commit 1eec5b3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

text/3621-derive-smart-pointer.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,15 +646,21 @@ introduce a `StableDeref` trait:
646646
unsafe trait StableDeref: Deref { }
647647
```
648648
Then we make it so that you can only coerce pinned pointers when they implement
649-
`StableDeref`. We can do that by modifying its implementation of
650-
[`CoerceUnsized`] to this:
649+
`StableDeref`. We can do that by modifying its trait implementations to this:
651650
```rs
652651
impl<T, U> CoerceUnsized<Pin<U>> for Pin<T>
653652
where
654653
T: CoerceUnsized<U>,
655654
T: StableDeref,
656655
U: StableDeref,
657656
{}
657+
658+
impl<T, U> DispatchFromDyn<Pin<U>> for Pin<T>
659+
where
660+
T: CoerceUnsized<U>,
661+
T: StableDeref,
662+
U: StableDeref,
663+
{}
658664
```
659665
This way, the user must implement the unsafe trait before they can coerce
660666
pinned versions of the pointer. Since the trait is unsafe, it is not our fault

0 commit comments

Comments
 (0)