Skip to content

Commit ab1347e

Browse files
Inline project
1 parent 09a3b8a commit ab1347e

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

futures-util/src/future/either.rs

+15-19
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ pub enum Either<A, B> {
3333
}
3434

3535
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-
4036
/// Convert `Pin<&Either<L, R>>` to `Either<Pin<&L>, Pin<&R>>`,
4137
/// pinned projections of the inner variants.
4238
pub fn as_pin_ref(self: Pin<&Self>) -> Either<Pin<&A>, Pin<&B>> {
@@ -109,7 +105,7 @@ where
109105
type Output = A::Output;
110106

111107
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
112-
match self.project() {
108+
match self.as_pin_mut() {
113109
Either::Left(x) => x.poll(cx),
114110
Either::Right(x) => x.poll(cx),
115111
}
@@ -137,7 +133,7 @@ where
137133
type Item = A::Item;
138134

139135
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
140-
match self.project() {
136+
match self.as_pin_mut() {
141137
Either::Left(x) => x.poll_next(cx),
142138
Either::Right(x) => x.poll_next(cx),
143139
}
@@ -173,28 +169,28 @@ where
173169
type Error = A::Error;
174170

175171
fn poll_ready(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
176-
match self.project() {
172+
match self.as_pin_mut() {
177173
Either::Left(x) => x.poll_ready(cx),
178174
Either::Right(x) => x.poll_ready(cx),
179175
}
180176
}
181177

182178
fn start_send(self: Pin<&mut Self>, item: Item) -> Result<(), Self::Error> {
183-
match self.project() {
179+
match self.as_pin_mut() {
184180
Either::Left(x) => x.start_send(item),
185181
Either::Right(x) => x.start_send(item),
186182
}
187183
}
188184

189185
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
190-
match self.project() {
186+
match self.as_pin_mut() {
191187
Either::Left(x) => x.poll_flush(cx),
192188
Either::Right(x) => x.poll_flush(cx),
193189
}
194190
}
195191

196192
fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
197-
match self.project() {
193+
match self.as_pin_mut() {
198194
Either::Left(x) => x.poll_close(cx),
199195
Either::Right(x) => x.poll_close(cx),
200196
}
@@ -222,7 +218,7 @@ mod if_std {
222218
cx: &mut Context<'_>,
223219
buf: &mut [u8],
224220
) -> Poll<Result<usize>> {
225-
match self.project() {
221+
match self.as_pin_mut() {
226222
Either::Left(x) => x.poll_read(cx, buf),
227223
Either::Right(x) => x.poll_read(cx, buf),
228224
}
@@ -233,7 +229,7 @@ mod if_std {
233229
cx: &mut Context<'_>,
234230
bufs: &mut [IoSliceMut<'_>],
235231
) -> Poll<Result<usize>> {
236-
match self.project() {
232+
match self.as_pin_mut() {
237233
Either::Left(x) => x.poll_read_vectored(cx, bufs),
238234
Either::Right(x) => x.poll_read_vectored(cx, bufs),
239235
}
@@ -250,7 +246,7 @@ mod if_std {
250246
cx: &mut Context<'_>,
251247
buf: &[u8],
252248
) -> Poll<Result<usize>> {
253-
match self.project() {
249+
match self.as_pin_mut() {
254250
Either::Left(x) => x.poll_write(cx, buf),
255251
Either::Right(x) => x.poll_write(cx, buf),
256252
}
@@ -261,21 +257,21 @@ mod if_std {
261257
cx: &mut Context<'_>,
262258
bufs: &[IoSlice<'_>],
263259
) -> Poll<Result<usize>> {
264-
match self.project() {
260+
match self.as_pin_mut() {
265261
Either::Left(x) => x.poll_write_vectored(cx, bufs),
266262
Either::Right(x) => x.poll_write_vectored(cx, bufs),
267263
}
268264
}
269265

270266
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>> {
271-
match self.project() {
267+
match self.as_pin_mut() {
272268
Either::Left(x) => x.poll_flush(cx),
273269
Either::Right(x) => x.poll_flush(cx),
274270
}
275271
}
276272

277273
fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>> {
278-
match self.project() {
274+
match self.as_pin_mut() {
279275
Either::Left(x) => x.poll_close(cx),
280276
Either::Right(x) => x.poll_close(cx),
281277
}
@@ -292,7 +288,7 @@ mod if_std {
292288
cx: &mut Context<'_>,
293289
pos: SeekFrom,
294290
) -> Poll<Result<u64>> {
295-
match self.project() {
291+
match self.as_pin_mut() {
296292
Either::Left(x) => x.poll_seek(cx, pos),
297293
Either::Right(x) => x.poll_seek(cx, pos),
298294
}
@@ -305,14 +301,14 @@ mod if_std {
305301
B: AsyncBufRead,
306302
{
307303
fn poll_fill_buf(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<&[u8]>> {
308-
match self.project() {
304+
match self.as_pin_mut() {
309305
Either::Left(x) => x.poll_fill_buf(cx),
310306
Either::Right(x) => x.poll_fill_buf(cx),
311307
}
312308
}
313309

314310
fn consume(self: Pin<&mut Self>, amt: usize) {
315-
match self.project() {
311+
match self.as_pin_mut() {
316312
Either::Left(x) => x.consume(amt),
317313
Either::Right(x) => x.consume(amt),
318314
}

0 commit comments

Comments
 (0)