100
100
#![ unstable( feature = "pin" , issue = "49150" ) ]
101
101
102
102
use fmt;
103
- use marker:: Sized ;
103
+ use marker:: { Sized , Unpin } ;
104
104
use ops:: { Deref , DerefMut , Receiver , CoerceUnsized , DispatchFromDyn } ;
105
105
106
- #[ doc( inline) ]
107
- pub use marker:: Unpin ;
108
-
109
106
/// A pinned pointer.
110
107
///
111
108
/// This is a wrapper around a kind of pointer which makes that pointer "pin" its
@@ -121,6 +118,7 @@ pub use marker::Unpin;
121
118
// cannot move the value behind `pointer`.
122
119
#[ unstable( feature = "pin" , issue = "49150" ) ]
123
120
#[ fundamental]
121
+ #[ repr( transparent) ]
124
122
#[ derive( Copy , Clone , Hash , Eq , PartialEq , Ord , PartialOrd ) ]
125
123
pub struct Pin < P > {
126
124
pointer : P ,
@@ -200,10 +198,10 @@ impl<'a, T: ?Sized> Pin<&'a T> {
200
198
/// because it is one of the fields of that value), and also that you do
201
199
/// not move out of the argument you receive to the interior function.
202
200
#[ unstable( feature = "pin" , issue = "49150" ) ]
203
- pub unsafe fn map_unchecked < U , F > ( this : Pin < & ' a T > , func : F ) -> Pin < & ' a U > where
201
+ pub unsafe fn map_unchecked < U , F > ( self : Pin < & ' a T > , func : F ) -> Pin < & ' a U > where
204
202
F : FnOnce ( & T ) -> & U ,
205
203
{
206
- let pointer = & * this . pointer ;
204
+ let pointer = & * self . pointer ;
207
205
let new_pointer = func ( pointer) ;
208
206
Pin :: new_unchecked ( new_pointer)
209
207
}
@@ -217,17 +215,17 @@ impl<'a, T: ?Sized> Pin<&'a T> {
217
215
/// with the same lifetime as the original `Pin`.
218
216
#[ unstable( feature = "pin" , issue = "49150" ) ]
219
217
#[ inline( always) ]
220
- pub fn get_ref ( this : Pin < & ' a T > ) -> & ' a T {
221
- this . pointer
218
+ pub fn get_ref ( self : Pin < & ' a T > ) -> & ' a T {
219
+ self . pointer
222
220
}
223
221
}
224
222
225
223
impl < ' a , T : ?Sized > Pin < & ' a mut T > {
226
224
/// Convert this `Pin<&mut T>` into a `Pin<&T>` with the same lifetime.
227
225
#[ unstable( feature = "pin" , issue = "49150" ) ]
228
226
#[ inline( always) ]
229
- pub fn into_ref ( this : Pin < & ' a mut T > ) -> Pin < & ' a T > {
230
- Pin { pointer : this . pointer }
227
+ pub fn into_ref ( self : Pin < & ' a mut T > ) -> Pin < & ' a T > {
228
+ Pin { pointer : self . pointer }
231
229
}
232
230
233
231
/// Get a mutable reference to the data inside of this `Pin`.
@@ -241,10 +239,10 @@ impl<'a, T: ?Sized> Pin<&'a mut T> {
241
239
/// with the same lifetime as the original `Pin`.
242
240
#[ unstable( feature = "pin" , issue = "49150" ) ]
243
241
#[ inline( always) ]
244
- pub fn get_mut ( this : Pin < & ' a mut T > ) -> & ' a mut T
242
+ pub fn get_mut ( self : Pin < & ' a mut T > ) -> & ' a mut T
245
243
where T : Unpin ,
246
244
{
247
- this . pointer
245
+ self . pointer
248
246
}
249
247
250
248
/// Get a mutable reference to the data inside of this `Pin`.
@@ -259,8 +257,8 @@ impl<'a, T: ?Sized> Pin<&'a mut T> {
259
257
/// instead.
260
258
#[ unstable( feature = "pin" , issue = "49150" ) ]
261
259
#[ inline( always) ]
262
- pub unsafe fn get_mut_unchecked ( this : Pin < & ' a mut T > ) -> & ' a mut T {
263
- this . pointer
260
+ pub unsafe fn get_unchecked_mut ( self : Pin < & ' a mut T > ) -> & ' a mut T {
261
+ self . pointer
264
262
}
265
263
266
264
/// Construct a new pin by mapping the interior value.
@@ -275,10 +273,10 @@ impl<'a, T: ?Sized> Pin<&'a mut T> {
275
273
/// because it is one of the fields of that value), and also that you do
276
274
/// not move out of the argument you receive to the interior function.
277
275
#[ unstable( feature = "pin" , issue = "49150" ) ]
278
- pub unsafe fn map_unchecked_mut < U , F > ( this : Pin < & ' a mut T > , func : F ) -> Pin < & ' a mut U > where
276
+ pub unsafe fn map_unchecked_mut < U , F > ( self : Pin < & ' a mut T > , func : F ) -> Pin < & ' a mut U > where
279
277
F : FnOnce ( & mut T ) -> & mut U ,
280
278
{
281
- let pointer = Pin :: get_mut_unchecked ( this ) ;
279
+ let pointer = Pin :: get_unchecked_mut ( self ) ;
282
280
let new_pointer = func ( pointer) ;
283
281
Pin :: new_unchecked ( new_pointer)
284
282
}
@@ -342,6 +340,3 @@ impl<'a, P, U> DispatchFromDyn<Pin<U>> for Pin<P>
342
340
where
343
341
P : DispatchFromDyn < U > ,
344
342
{ }
345
-
346
- #[ unstable( feature = "pin" , issue = "49150" ) ]
347
- impl < P > Unpin for Pin < P > { }
0 commit comments