Skip to content

Commit fe2f40a

Browse files
committed
Add an example for Pin::new()
1 parent ddfe1e8 commit fe2f40a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

library/core/src/pin.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,13 @@ 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+
/// let val: u8 = 5;
493+
/// let pinned: Pin<&u8> = Pin::new(&val);
494+
/// ```
488495
#[inline(always)]
489496
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
490497
#[stable(feature = "pin", since = "1.33.0")]

0 commit comments

Comments
 (0)