File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -489,7 +489,10 @@ impl<P: Deref<Target: Unpin>> Pin<P> {
489
489
/// # Examples
490
490
///
491
491
/// ```
492
+ /// use std::pin::Pin;
493
+ ///
492
494
/// let val: u8 = 5;
495
+ /// // Wrap the value in a pin to make sure it doesn't move
493
496
/// let pinned: Pin<&u8> = Pin::new(&val);
494
497
/// ```
495
498
#[ inline( always) ]
@@ -505,6 +508,17 @@ impl<P: Deref<Target: Unpin>> Pin<P> {
505
508
///
506
509
/// This requires that the data inside this `Pin` is [`Unpin`] so that we
507
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
+ /// ```
508
522
#[ inline( always) ]
509
523
#[ rustc_const_unstable( feature = "const_pin" , issue = "76654" ) ]
510
524
#[ stable( feature = "pin_into_inner" , since = "1.39.0" ) ]
You can’t perform that action at this time.
0 commit comments