@@ -491,9 +491,9 @@ impl<P: Deref<Target: Unpin>> Pin<P> {
491491 /// ```
492492 /// use std::pin::Pin;
493493 ///
494- /// let val: u8 = 5;
494+ /// let mut val: u8 = 5;
495495 /// // We can pin the value, since it doesn't care about being moved
496- /// let pinned: Pin<&u8> = Pin::new(&val);
496+ /// let mut pinned: Pin<&mut u8> = Pin::new(&mut val);
497497 /// ```
498498 #[ inline( always) ]
499499 #[ rustc_const_unstable( feature = "const_pin" , issue = "76654" ) ]
@@ -514,7 +514,8 @@ impl<P: Deref<Target: Unpin>> Pin<P> {
514514 /// ```
515515 /// use std::pin::Pin;
516516 ///
517- /// let pinned: Pin<&u8> = Pin::new(&5);
517+ /// let mut val: u8 = 5;
518+ /// let pinned: Pin<&mut u8> = Pin::new(&mut val);
518519 /// // Unwrap the pin to get a reference to the value
519520 /// let r = Pin::into_inner(pinned);
520521 /// assert_eq!(*r, 5);
@@ -728,6 +729,18 @@ impl<P: DerefMut> Pin<P> {
728729 ///
729730 /// This overwrites pinned data, but that is okay: its destructor gets
730731 /// run before being overwritten, so no pinning guarantee is violated.
732+ ///
733+ /// # Example
734+ ///
735+ /// ```
736+ /// use std::pin::Pin;
737+ ///
738+ /// let mut val: u8 = 5;
739+ /// let mut pinned: Pin<&mut u8> = Pin::new(&mut val);
740+ /// println!("{}", pinned); // 5
741+ /// pinned.as_mut().set(10);
742+ /// println!("{}", pinned); // 10
743+ /// ```
731744 #[ stable( feature = "pin" , since = "1.33.0" ) ]
732745 #[ inline( always) ]
733746 pub fn set ( & mut self , value : P :: Target )
0 commit comments