@@ -485,6 +485,16 @@ impl<P: Deref<Target: Unpin>> Pin<P> {
485485 ///
486486 /// Unlike `Pin::new_unchecked`, this method is safe because the pointer
487487 /// `P` dereferences to an [`Unpin`] type, which cancels the pinning guarantees.
488+ ///
489+ /// # Examples
490+ ///
491+ /// ```
492+ /// use std::pin::Pin;
493+ ///
494+ /// let mut val: u8 = 5;
495+ /// // We can pin the value, since it doesn't care about being moved
496+ /// let mut pinned: Pin<&mut u8> = Pin::new(&mut val);
497+ /// ```
488498 #[ inline( always) ]
489499 #[ rustc_const_unstable( feature = "const_pin" , issue = "76654" ) ]
490500 #[ stable( feature = "pin" , since = "1.33.0" ) ]
@@ -496,8 +506,20 @@ impl<P: Deref<Target: Unpin>> Pin<P> {
496506
497507 /// Unwraps this `Pin<P>` returning the underlying pointer.
498508 ///
499- /// This requires that the data inside this `Pin` is [`Unpin`] so that we
509+ /// This requires that the data inside this `Pin` implements [`Unpin`] so that we
500510 /// can ignore the pinning invariants when unwrapping it.
511+ ///
512+ /// # Examples
513+ ///
514+ /// ```
515+ /// use std::pin::Pin;
516+ ///
517+ /// let mut val: u8 = 5;
518+ /// let pinned: Pin<&mut u8> = Pin::new(&mut val);
519+ /// // Unwrap the pin to get a reference to the value
520+ /// let r = Pin::into_inner(pinned);
521+ /// assert_eq!(*r, 5);
522+ /// ```
501523 #[ inline( always) ]
502524 #[ rustc_const_unstable( feature = "const_pin" , issue = "76654" ) ]
503525 #[ stable( feature = "pin_into_inner" , since = "1.39.0" ) ]
@@ -707,6 +729,18 @@ impl<P: DerefMut> Pin<P> {
707729 ///
708730 /// This overwrites pinned data, but that is okay: its destructor gets
709731 /// 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+ /// ```
710744 #[ stable( feature = "pin" , since = "1.33.0" ) ]
711745 #[ inline( always) ]
712746 pub fn set ( & mut self , value : P :: Target )
0 commit comments