@@ -609,16 +609,27 @@ unsafe impl<'a, T: ?Sized> Freeze for &'a mut T {}
609
609
/// this trait cannot prevent types from moving by itself.
610
610
///
611
611
/// Instead it can be used to prevent moves through the type system,
612
- /// by controlling the behavior of special pointers types like [`PinMut`],
613
- /// which "pin" the type in place by wrapping it in a type which can only be dereferenced immutably .
612
+ /// 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 .
614
614
///
615
615
/// 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 [`swap`].
616
+ /// which then allows it to move out of said pointers, with functions such as [`replace`].
617
+ ///
618
+ /// So this, for example, can only be done on types implementing `Unpin`:
619
+ ///
620
+ /// ```rust
621
+ /// #![feature(pin)]
622
+ /// use std::mem::{PinMut, replace};
623
+ ///
624
+ /// let mut string = "this".to_string();
625
+ /// let mut pinned_string = PinMut::new(&mut string);
626
+ /// replace(&mut *pinned_string, "other".to_string());
627
+ /// ```
617
628
///
618
629
/// This trait is automatically implemented for almost every type.
619
630
///
620
631
/// [`PinMut`]: ../mem/struct.PinMut.html
621
- /// [`swap `]: ../mem/fn.swap .html
632
+ /// [`replace `]: ../mem/fn.replace .html
622
633
#[ unstable( feature = "pin" , issue = "49150" ) ]
623
634
pub auto trait Unpin { }
624
635
0 commit comments