@@ -1101,69 +1101,72 @@ impl<T: ::hash::Hash> ::hash::Hash for ManuallyDrop<T> {
11011101/// value implements the `Unpin` trait.
11021102#[ unstable( feature = "pin" , issue = "49150" ) ]
11031103#[ fundamental]
1104- pub struct Pin < ' a , T : ?Sized + ' a > {
1104+ pub struct PinMut < ' a , T : ?Sized + ' a > {
11051105 inner : & ' a mut T ,
11061106}
11071107
11081108#[ unstable( feature = "pin" , issue = "49150" ) ]
1109- impl < ' a , T : ?Sized + Unpin > Pin < ' a , T > {
1110- /// Construct a new `Pin ` around a reference to some data of a type that
1109+ impl < ' a , T : ?Sized + Unpin > PinMut < ' a , T > {
1110+ /// Construct a new `PinMut ` around a reference to some data of a type that
11111111 /// implements `Unpin`.
11121112 #[ unstable( feature = "pin" , issue = "49150" ) ]
1113- pub fn new ( reference : & ' a mut T ) -> Pin < ' a , T > {
1114- Pin { inner : reference }
1113+ pub fn new ( reference : & ' a mut T ) -> PinMut < ' a , T > {
1114+ PinMut { inner : reference }
11151115 }
11161116}
11171117
11181118
11191119#[ unstable( feature = "pin" , issue = "49150" ) ]
1120- impl < ' a , T : ?Sized > Pin < ' a , T > {
1121- /// Construct a new `Pin ` around a reference to some data of a type that
1120+ impl < ' a , T : ?Sized > PinMut < ' a , T > {
1121+ /// Construct a new `PinMut ` around a reference to some data of a type that
11221122 /// may or may not implement `Unpin`.
11231123 ///
11241124 /// This constructor is unsafe because we do not know what will happen with
11251125 /// that data after the reference ends. If you cannot guarantee that the
11261126 /// data will never move again, calling this constructor is invalid.
11271127 #[ unstable( feature = "pin" , issue = "49150" ) ]
1128- pub unsafe fn new_unchecked ( reference : & ' a mut T ) -> Pin < ' a , T > {
1129- Pin { inner : reference }
1128+ pub unsafe fn new_unchecked ( reference : & ' a mut T ) -> PinMut < ' a , T > {
1129+ PinMut { inner : reference }
11301130 }
11311131
1132- /// Borrow a Pin for a shorter lifetime than it already has.
1132+ /// Reborrow a `PinMut` for a shorter lifetime.
1133+ ///
1134+ /// For example, `PinMut::get_mut(x.reborrow())` (unsafely) returns a
1135+ /// short-lived mutable reference reborrowing from `x`.
11331136 #[ unstable( feature = "pin" , issue = "49150" ) ]
1134- pub fn borrow < ' b > ( this : & ' b mut Pin < ' a , T > ) -> Pin < ' b , T > {
1135- Pin { inner : this . inner }
1137+ pub fn reborrow < ' b > ( & ' b mut self ) -> PinMut < ' b , T > {
1138+ PinMut { inner : self . inner }
11361139 }
11371140
1138- /// Get a mutable reference to the data inside of this `Pin `.
1141+ /// Get a mutable reference to the data inside of this `PinMut `.
11391142 ///
11401143 /// This function is unsafe. You must guarantee that you will never move
11411144 /// the data out of the mutable reference you receive when you call this
11421145 /// function.
11431146 #[ unstable( feature = "pin" , issue = "49150" ) ]
1144- pub unsafe fn get_mut < ' b > ( this : & ' b mut Pin < ' a , T > ) -> & ' b mut T {
1147+ pub unsafe fn get_mut ( this : PinMut < ' a , T > ) -> & ' a mut T {
11451148 this. inner
11461149 }
11471150
11481151 /// Construct a new pin by mapping the interior value.
11491152 ///
1150- /// For example, if you wanted to get a `Pin ` of a field of something, you
1153+ /// For example, if you wanted to get a `PinMut ` of a field of something, you
11511154 /// could use this to get access to that field in one line of code.
11521155 ///
11531156 /// This function is unsafe. You must guarantee that the data you return
11541157 /// will not move so long as the argument value does not move (for example,
11551158 /// because it is one of the fields of that value), and also that you do
11561159 /// not move out of the argument you receive to the interior function.
11571160 #[ unstable( feature = "pin" , issue = "49150" ) ]
1158- pub unsafe fn map < ' b , U , F > ( this : & ' b mut Pin < ' a , T > , f : F ) -> Pin < ' b , U > where
1161+ pub unsafe fn map < U , F > ( this : PinMut < ' a , T > , f : F ) -> PinMut < ' a , U > where
11591162 F : FnOnce ( & mut T ) -> & mut U
11601163 {
1161- Pin { inner : f ( this. inner ) }
1164+ PinMut { inner : f ( this. inner ) }
11621165 }
11631166}
11641167
11651168#[ unstable( feature = "pin" , issue = "49150" ) ]
1166- impl < ' a , T : ?Sized > Deref for Pin < ' a , T > {
1169+ impl < ' a , T : ?Sized > Deref for PinMut < ' a , T > {
11671170 type Target = T ;
11681171
11691172 fn deref ( & self ) -> & T {
@@ -1172,35 +1175,35 @@ impl<'a, T: ?Sized> Deref for Pin<'a, T> {
11721175}
11731176
11741177#[ unstable( feature = "pin" , issue = "49150" ) ]
1175- impl < ' a , T : ?Sized + Unpin > DerefMut for Pin < ' a , T > {
1178+ impl < ' a , T : ?Sized + Unpin > DerefMut for PinMut < ' a , T > {
11761179 fn deref_mut ( & mut self ) -> & mut T {
11771180 self . inner
11781181 }
11791182}
11801183
11811184#[ unstable( feature = "pin" , issue = "49150" ) ]
1182- impl < ' a , T : fmt:: Debug + ?Sized > fmt:: Debug for Pin < ' a , T > {
1185+ impl < ' a , T : fmt:: Debug + ?Sized > fmt:: Debug for PinMut < ' a , T > {
11831186 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
11841187 fmt:: Debug :: fmt ( & * * self , f)
11851188 }
11861189}
11871190
11881191#[ unstable( feature = "pin" , issue = "49150" ) ]
1189- impl < ' a , T : fmt:: Display + ?Sized > fmt:: Display for Pin < ' a , T > {
1192+ impl < ' a , T : fmt:: Display + ?Sized > fmt:: Display for PinMut < ' a , T > {
11901193 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
11911194 fmt:: Display :: fmt ( & * * self , f)
11921195 }
11931196}
11941197
11951198#[ unstable( feature = "pin" , issue = "49150" ) ]
1196- impl < ' a , T : ?Sized > fmt:: Pointer for Pin < ' a , T > {
1199+ impl < ' a , T : ?Sized > fmt:: Pointer for PinMut < ' a , T > {
11971200 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
11981201 fmt:: Pointer :: fmt ( & ( & * self . inner as * const T ) , f)
11991202 }
12001203}
12011204
12021205#[ unstable( feature = "pin" , issue = "49150" ) ]
1203- impl < ' a , T : ?Sized + Unsize < U > , U : ?Sized > CoerceUnsized < Pin < ' a , U > > for Pin < ' a , T > { }
1206+ impl < ' a , T : ?Sized + Unsize < U > , U : ?Sized > CoerceUnsized < PinMut < ' a , U > > for PinMut < ' a , T > { }
12041207
12051208#[ unstable( feature = "pin" , issue = "49150" ) ]
1206- unsafe impl < ' a , T : ?Sized > Unpin for Pin < ' a , T > { }
1209+ unsafe impl < ' a , T : ?Sized > Unpin for PinMut < ' a , T > { }
0 commit comments