Skip to content

Commit 6ae915b

Browse files
committed
clarify use of Unpin and pinning types
1 parent 03530fa commit 6ae915b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/libcore/marker.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -610,10 +610,10 @@ unsafe impl<'a, T: ?Sized> Freeze for &'a mut T {}
610610
///
611611
/// Instead it can be used to prevent moves through the type system,
612612
/// by controlling the behavior of special pointer types like [`PinMut`],
613-
/// which "pin" the type in place by not allowing it to be moved out via mutable references.
613+
/// which "pin" the type in place by not allowing it to be moved out of them.
614614
///
615615
/// Implementing this trait lifts the restrictions of pinning off a type,
616-
/// which then allows it to move out of said pointers, with functions such as [`replace`].
616+
/// which then allows it to move out with functions such as [`replace`].
617617
///
618618
/// So this, for example, can only be done on types implementing `Unpin`:
619619
///
@@ -623,6 +623,8 @@ unsafe impl<'a, T: ?Sized> Freeze for &'a mut T {}
623623
///
624624
/// let mut string = "this".to_string();
625625
/// let mut pinned_string = PinMut::new(&mut string);
626+
///
627+
/// // dereferencing the pointer mutably is only possible because String implements Unpin
626628
/// replace(&mut *pinned_string, "other".to_string());
627629
/// ```
628630
///

0 commit comments

Comments
 (0)