File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -485,6 +485,16 @@ impl<P: Deref<Target: Unpin>> Pin<P> {
485
485
///
486
486
/// Unlike `Pin::new_unchecked`, this method is safe because the pointer
487
487
/// `P` dereferences to an [`Unpin`] type, which cancels the pinning guarantees.
488
+ ///
489
+ /// # Examples
490
+ ///
491
+ /// ```
492
+ /// use std::pin::Pin;
493
+ ///
494
+ /// let val: u8 = 5;
495
+ /// // Wrap the value in a pin to make sure it doesn't move
496
+ /// let pinned: Pin<&u8> = Pin::new(&val);
497
+ /// ```
488
498
#[ inline( always) ]
489
499
#[ rustc_const_unstable( feature = "const_pin" , issue = "76654" ) ]
490
500
#[ stable( feature = "pin" , since = "1.33.0" ) ]
@@ -498,6 +508,17 @@ impl<P: Deref<Target: Unpin>> Pin<P> {
498
508
///
499
509
/// This requires that the data inside this `Pin` is [`Unpin`] so that we
500
510
/// can ignore the pinning invariants when unwrapping it.
511
+ ///
512
+ /// # Examples
513
+ ///
514
+ /// ```
515
+ /// use std::pin::Pin;
516
+ ///
517
+ /// let pinned: Pin<&u8> = Pin::new(&5);
518
+ /// // Unwrap the pin to get a reference to the value
519
+ /// let r = Pin::into_inner(pinned);
520
+ /// assert_eq!(*r, 5);
521
+ /// ```
501
522
#[ inline( always) ]
502
523
#[ rustc_const_unstable( feature = "const_pin" , issue = "76654" ) ]
503
524
#[ stable( feature = "pin_into_inner" , since = "1.39.0" ) ]
You can’t perform that action at this time.
0 commit comments