@@ -1101,69 +1101,72 @@ impl<T: ::hash::Hash> ::hash::Hash for ManuallyDrop<T> {
1101
1101
/// value implements the `Unpin` trait.
1102
1102
#[ unstable( feature = "pin" , issue = "49150" ) ]
1103
1103
#[ fundamental]
1104
- pub struct Pin < ' a , T : ?Sized + ' a > {
1104
+ pub struct PinMut < ' a , T : ?Sized + ' a > {
1105
1105
inner : & ' a mut T ,
1106
1106
}
1107
1107
1108
1108
#[ 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
1111
1111
/// implements `Unpin`.
1112
1112
#[ 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 }
1115
1115
}
1116
1116
}
1117
1117
1118
1118
1119
1119
#[ 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
1122
1122
/// may or may not implement `Unpin`.
1123
1123
///
1124
1124
/// This constructor is unsafe because we do not know what will happen with
1125
1125
/// that data after the reference ends. If you cannot guarantee that the
1126
1126
/// data will never move again, calling this constructor is invalid.
1127
1127
#[ 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 }
1130
1130
}
1131
1131
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`.
1133
1136
#[ 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 }
1136
1139
}
1137
1140
1138
- /// Get a mutable reference to the data inside of this `Pin `.
1141
+ /// Get a mutable reference to the data inside of this `PinMut `.
1139
1142
///
1140
1143
/// This function is unsafe. You must guarantee that you will never move
1141
1144
/// the data out of the mutable reference you receive when you call this
1142
1145
/// function.
1143
1146
#[ 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 {
1145
1148
this. inner
1146
1149
}
1147
1150
1148
1151
/// Construct a new pin by mapping the interior value.
1149
1152
///
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
1151
1154
/// could use this to get access to that field in one line of code.
1152
1155
///
1153
1156
/// This function is unsafe. You must guarantee that the data you return
1154
1157
/// will not move so long as the argument value does not move (for example,
1155
1158
/// because it is one of the fields of that value), and also that you do
1156
1159
/// not move out of the argument you receive to the interior function.
1157
1160
#[ 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
1159
1162
F : FnOnce ( & mut T ) -> & mut U
1160
1163
{
1161
- Pin { inner : f ( this. inner ) }
1164
+ PinMut { inner : f ( this. inner ) }
1162
1165
}
1163
1166
}
1164
1167
1165
1168
#[ 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 > {
1167
1170
type Target = T ;
1168
1171
1169
1172
fn deref ( & self ) -> & T {
@@ -1172,35 +1175,35 @@ impl<'a, T: ?Sized> Deref for Pin<'a, T> {
1172
1175
}
1173
1176
1174
1177
#[ 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 > {
1176
1179
fn deref_mut ( & mut self ) -> & mut T {
1177
1180
self . inner
1178
1181
}
1179
1182
}
1180
1183
1181
1184
#[ 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 > {
1183
1186
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1184
1187
fmt:: Debug :: fmt ( & * * self , f)
1185
1188
}
1186
1189
}
1187
1190
1188
1191
#[ 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 > {
1190
1193
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1191
1194
fmt:: Display :: fmt ( & * * self , f)
1192
1195
}
1193
1196
}
1194
1197
1195
1198
#[ 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 > {
1197
1200
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1198
1201
fmt:: Pointer :: fmt ( & ( & * self . inner as * const T ) , f)
1199
1202
}
1200
1203
}
1201
1204
1202
1205
#[ 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 > { }
1204
1207
1205
1208
#[ 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