File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -618,14 +618,16 @@ unsafe impl<T: ?Sized> Freeze for &mut T {}
618
618
/// So this, for example, can only be done on types implementing `Unpin`:
619
619
///
620
620
/// ```rust
621
- /// use std::mem::replace ;
621
+ /// use std::mem;
622
622
/// use std::pin::Pin;
623
623
///
624
624
/// let mut string = "this".to_string();
625
625
/// let mut pinned_string = Pin::new(&mut string);
626
626
///
627
- /// // dereferencing the pointer mutably is only possible because String implements Unpin
628
- /// replace(&mut *pinned_string, "other".to_string());
627
+ /// // We need a mutable reference to call `mem::replace`.
628
+ /// // We can obtain such a reference by (implicitly) invoking `Pin::deref_mut`,
629
+ /// // but that is only possible because `String` implements `Unpin`.
630
+ /// mem::replace(&mut *pinned_string, "other".to_string());
629
631
/// ```
630
632
///
631
633
/// This trait is automatically implemented for almost every type.
You can’t perform that action at this time.
0 commit comments