@@ -1451,6 +1451,33 @@ impl<Ptr: Deref> Pin<Ptr> {
1451
1451
unsafe { self . get_unchecked_mut ( ) } . as_mut ( )
1452
1452
}
1453
1453
1454
+ /// Unwraps this `Pin<Ptr>`, returning the underlying `Ptr`.
1455
+ ///
1456
+ /// # Safety
1457
+ ///
1458
+ /// This function is unsafe. You must guarantee that you will continue to
1459
+ /// treat the pointer `Ptr` as pinned after you call this function, so that
1460
+ /// the invariants on the `Pin` type can be upheld. If the code using the
1461
+ /// resulting `Ptr` does not continue to maintain the pinning invariants that
1462
+ /// is a violation of the API contract and may lead to undefined behavior in
1463
+ /// later (safe) operations.
1464
+ ///
1465
+ /// Note that you must be able to guarantee that the data pointed to by `Ptr`
1466
+ /// will be treated as pinned all the way until its `drop` handler is complete!
1467
+ ///
1468
+ /// *For more information, see the [`pin` module docs][self]*
1469
+ ///
1470
+ /// If the underlying data is [`Unpin`], [`Pin::into_inner`] should be used
1471
+ /// instead.
1472
+ #[ inline( always) ]
1473
+ #[ rustc_const_unstable( feature = "const_pin" , issue = "76654" ) ]
1474
+ #[ stable( feature = "pin_into_inner" , since = "1.39.0" ) ]
1475
+ pub const unsafe fn into_inner_unchecked ( pin : Pin < Ptr > ) -> Ptr {
1476
+ pin. __pointer
1477
+ }
1478
+ }
1479
+
1480
+ impl < Ptr : DerefMut > Pin < Ptr > {
1454
1481
/// Assigns a new value to the memory location pointed to by the `Pin<Ptr>`.
1455
1482
///
1456
1483
/// This overwrites pinned data, but that is okay: the original pinned value's destructor gets
@@ -1475,36 +1502,10 @@ impl<Ptr: Deref> Pin<Ptr> {
1475
1502
#[ inline( always) ]
1476
1503
pub fn set ( & mut self , value : Ptr :: Target )
1477
1504
where
1478
- Ptr : DerefMut ,
1479
1505
Ptr :: Target : Sized ,
1480
1506
{
1481
1507
* ( self . __pointer ) = value;
1482
1508
}
1483
-
1484
- /// Unwraps this `Pin<Ptr>`, returning the underlying `Ptr`.
1485
- ///
1486
- /// # Safety
1487
- ///
1488
- /// This function is unsafe. You must guarantee that you will continue to
1489
- /// treat the pointer `Ptr` as pinned after you call this function, so that
1490
- /// the invariants on the `Pin` type can be upheld. If the code using the
1491
- /// resulting `Ptr` does not continue to maintain the pinning invariants that
1492
- /// is a violation of the API contract and may lead to undefined behavior in
1493
- /// later (safe) operations.
1494
- ///
1495
- /// Note that you must be able to guarantee that the data pointed to by `Ptr`
1496
- /// will be treated as pinned all the way until its `drop` handler is complete!
1497
- ///
1498
- /// *For more information, see the [`pin` module docs][self]*
1499
- ///
1500
- /// If the underlying data is [`Unpin`], [`Pin::into_inner`] should be used
1501
- /// instead.
1502
- #[ inline( always) ]
1503
- #[ rustc_const_unstable( feature = "const_pin" , issue = "76654" ) ]
1504
- #[ stable( feature = "pin_into_inner" , since = "1.39.0" ) ]
1505
- pub const unsafe fn into_inner_unchecked ( pin : Pin < Ptr > ) -> Ptr {
1506
- pin. __pointer
1507
- }
1508
1509
}
1509
1510
1510
1511
impl < ' a , T : ?Sized > Pin < & ' a T > {
0 commit comments