@@ -33,10 +33,6 @@ pub enum Either<A, B> {
33
33
}
34
34
35
35
impl < A , B > Either < A , B > {
36
- fn project ( self : Pin < & mut Self > ) -> Either < Pin < & mut A > , Pin < & mut B > > {
37
- self . as_pin_mut ( )
38
- }
39
-
40
36
/// Convert `Pin<&Either<L, R>>` to `Either<Pin<&L>, Pin<&R>>`,
41
37
/// pinned projections of the inner variants.
42
38
pub fn as_pin_ref ( self : Pin < & Self > ) -> Either < Pin < & A > , Pin < & B > > {
@@ -109,7 +105,7 @@ where
109
105
type Output = A :: Output ;
110
106
111
107
fn poll ( self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < Self :: Output > {
112
- match self . project ( ) {
108
+ match self . as_pin_mut ( ) {
113
109
Either :: Left ( x) => x. poll ( cx) ,
114
110
Either :: Right ( x) => x. poll ( cx) ,
115
111
}
@@ -137,7 +133,7 @@ where
137
133
type Item = A :: Item ;
138
134
139
135
fn poll_next ( self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < Option < Self :: Item > > {
140
- match self . project ( ) {
136
+ match self . as_pin_mut ( ) {
141
137
Either :: Left ( x) => x. poll_next ( cx) ,
142
138
Either :: Right ( x) => x. poll_next ( cx) ,
143
139
}
@@ -173,28 +169,28 @@ where
173
169
type Error = A :: Error ;
174
170
175
171
fn poll_ready ( self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < Result < ( ) , Self :: Error > > {
176
- match self . project ( ) {
172
+ match self . as_pin_mut ( ) {
177
173
Either :: Left ( x) => x. poll_ready ( cx) ,
178
174
Either :: Right ( x) => x. poll_ready ( cx) ,
179
175
}
180
176
}
181
177
182
178
fn start_send ( self : Pin < & mut Self > , item : Item ) -> Result < ( ) , Self :: Error > {
183
- match self . project ( ) {
179
+ match self . as_pin_mut ( ) {
184
180
Either :: Left ( x) => x. start_send ( item) ,
185
181
Either :: Right ( x) => x. start_send ( item) ,
186
182
}
187
183
}
188
184
189
185
fn poll_flush ( self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < Result < ( ) , Self :: Error > > {
190
- match self . project ( ) {
186
+ match self . as_pin_mut ( ) {
191
187
Either :: Left ( x) => x. poll_flush ( cx) ,
192
188
Either :: Right ( x) => x. poll_flush ( cx) ,
193
189
}
194
190
}
195
191
196
192
fn poll_close ( self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < Result < ( ) , Self :: Error > > {
197
- match self . project ( ) {
193
+ match self . as_pin_mut ( ) {
198
194
Either :: Left ( x) => x. poll_close ( cx) ,
199
195
Either :: Right ( x) => x. poll_close ( cx) ,
200
196
}
@@ -222,7 +218,7 @@ mod if_std {
222
218
cx : & mut Context < ' _ > ,
223
219
buf : & mut [ u8 ] ,
224
220
) -> Poll < Result < usize > > {
225
- match self . project ( ) {
221
+ match self . as_pin_mut ( ) {
226
222
Either :: Left ( x) => x. poll_read ( cx, buf) ,
227
223
Either :: Right ( x) => x. poll_read ( cx, buf) ,
228
224
}
@@ -233,7 +229,7 @@ mod if_std {
233
229
cx : & mut Context < ' _ > ,
234
230
bufs : & mut [ IoSliceMut < ' _ > ] ,
235
231
) -> Poll < Result < usize > > {
236
- match self . project ( ) {
232
+ match self . as_pin_mut ( ) {
237
233
Either :: Left ( x) => x. poll_read_vectored ( cx, bufs) ,
238
234
Either :: Right ( x) => x. poll_read_vectored ( cx, bufs) ,
239
235
}
@@ -250,7 +246,7 @@ mod if_std {
250
246
cx : & mut Context < ' _ > ,
251
247
buf : & [ u8 ] ,
252
248
) -> Poll < Result < usize > > {
253
- match self . project ( ) {
249
+ match self . as_pin_mut ( ) {
254
250
Either :: Left ( x) => x. poll_write ( cx, buf) ,
255
251
Either :: Right ( x) => x. poll_write ( cx, buf) ,
256
252
}
@@ -261,21 +257,21 @@ mod if_std {
261
257
cx : & mut Context < ' _ > ,
262
258
bufs : & [ IoSlice < ' _ > ] ,
263
259
) -> Poll < Result < usize > > {
264
- match self . project ( ) {
260
+ match self . as_pin_mut ( ) {
265
261
Either :: Left ( x) => x. poll_write_vectored ( cx, bufs) ,
266
262
Either :: Right ( x) => x. poll_write_vectored ( cx, bufs) ,
267
263
}
268
264
}
269
265
270
266
fn poll_flush ( self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < Result < ( ) > > {
271
- match self . project ( ) {
267
+ match self . as_pin_mut ( ) {
272
268
Either :: Left ( x) => x. poll_flush ( cx) ,
273
269
Either :: Right ( x) => x. poll_flush ( cx) ,
274
270
}
275
271
}
276
272
277
273
fn poll_close ( self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < Result < ( ) > > {
278
- match self . project ( ) {
274
+ match self . as_pin_mut ( ) {
279
275
Either :: Left ( x) => x. poll_close ( cx) ,
280
276
Either :: Right ( x) => x. poll_close ( cx) ,
281
277
}
@@ -292,7 +288,7 @@ mod if_std {
292
288
cx : & mut Context < ' _ > ,
293
289
pos : SeekFrom ,
294
290
) -> Poll < Result < u64 > > {
295
- match self . project ( ) {
291
+ match self . as_pin_mut ( ) {
296
292
Either :: Left ( x) => x. poll_seek ( cx, pos) ,
297
293
Either :: Right ( x) => x. poll_seek ( cx, pos) ,
298
294
}
@@ -305,14 +301,14 @@ mod if_std {
305
301
B : AsyncBufRead ,
306
302
{
307
303
fn poll_fill_buf ( self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < Result < & [ u8 ] > > {
308
- match self . project ( ) {
304
+ match self . as_pin_mut ( ) {
309
305
Either :: Left ( x) => x. poll_fill_buf ( cx) ,
310
306
Either :: Right ( x) => x. poll_fill_buf ( cx) ,
311
307
}
312
308
}
313
309
314
310
fn consume ( self : Pin < & mut Self > , amt : usize ) {
315
- match self . project ( ) {
311
+ match self . as_pin_mut ( ) {
316
312
Either :: Left ( x) => x. consume ( amt) ,
317
313
Either :: Right ( x) => x. consume ( amt) ,
318
314
}
0 commit comments