100100#![ unstable( feature = "pin" , issue = "49150" ) ]
101101
102102use fmt;
103- use marker:: Sized ;
103+ use marker:: { Sized , Unpin } ;
104104use ops:: { Deref , DerefMut , Receiver , CoerceUnsized , DispatchFromDyn } ;
105105
106- #[ doc( inline) ]
107- pub use marker:: Unpin ;
108-
109106/// A pinned pointer.
110107///
111108/// This is a wrapper around a kind of pointer which makes that pointer "pin" its
@@ -121,6 +118,7 @@ pub use marker::Unpin;
121118// cannot move the value behind `pointer`.
122119#[ unstable( feature = "pin" , issue = "49150" ) ]
123120#[ fundamental]
121+ #[ repr( transparent) ]
124122#[ derive( Copy , Clone , Hash , Eq , PartialEq , Ord , PartialOrd ) ]
125123pub struct Pin < P > {
126124 pointer : P ,
@@ -200,10 +198,10 @@ impl<'a, T: ?Sized> Pin<&'a T> {
200198 /// because it is one of the fields of that value), and also that you do
201199 /// not move out of the argument you receive to the interior function.
202200 #[ 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
204202 F : FnOnce ( & T ) -> & U ,
205203 {
206- let pointer = & * this . pointer ;
204+ let pointer = & * self . pointer ;
207205 let new_pointer = func ( pointer) ;
208206 Pin :: new_unchecked ( new_pointer)
209207 }
@@ -217,17 +215,17 @@ impl<'a, T: ?Sized> Pin<&'a T> {
217215 /// with the same lifetime as the original `Pin`.
218216 #[ unstable( feature = "pin" , issue = "49150" ) ]
219217 #[ 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
222220 }
223221}
224222
225223impl < ' a , T : ?Sized > Pin < & ' a mut T > {
226224 /// Convert this `Pin<&mut T>` into a `Pin<&T>` with the same lifetime.
227225 #[ unstable( feature = "pin" , issue = "49150" ) ]
228226 #[ 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 }
231229 }
232230
233231 /// Get a mutable reference to the data inside of this `Pin`.
@@ -241,10 +239,10 @@ impl<'a, T: ?Sized> Pin<&'a mut T> {
241239 /// with the same lifetime as the original `Pin`.
242240 #[ unstable( feature = "pin" , issue = "49150" ) ]
243241 #[ 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
245243 where T : Unpin ,
246244 {
247- this . pointer
245+ self . pointer
248246 }
249247
250248 /// Get a mutable reference to the data inside of this `Pin`.
@@ -259,8 +257,8 @@ impl<'a, T: ?Sized> Pin<&'a mut T> {
259257 /// instead.
260258 #[ unstable( feature = "pin" , issue = "49150" ) ]
261259 #[ 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
264262 }
265263
266264 /// Construct a new pin by mapping the interior value.
@@ -275,10 +273,10 @@ impl<'a, T: ?Sized> Pin<&'a mut T> {
275273 /// because it is one of the fields of that value), and also that you do
276274 /// not move out of the argument you receive to the interior function.
277275 #[ 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
279277 F : FnOnce ( & mut T ) -> & mut U ,
280278 {
281- let pointer = Pin :: get_mut_unchecked ( this ) ;
279+ let pointer = Pin :: get_unchecked_mut ( self ) ;
282280 let new_pointer = func ( pointer) ;
283281 Pin :: new_unchecked ( new_pointer)
284282 }
@@ -342,6 +340,3 @@ impl<'a, P, U> DispatchFromDyn<Pin<U>> for Pin<P>
342340where
343341 P : DispatchFromDyn < U > ,
344342{ }
345-
346- #[ unstable( feature = "pin" , issue = "49150" ) ]
347- impl < P > Unpin for Pin < P > { }
0 commit comments