Skip to content

Commit 756384f

Browse files
authored
Replace internal PollExt trait with Poll inherent methods (#625)
Signed-off-by: Miguel Guarniz <[email protected]>
1 parent fd4040d commit 756384f

File tree

3 files changed

+4
-47
lines changed

3 files changed

+4
-47
lines changed

src/lib.rs

-41
Original file line numberDiff line numberDiff line change
@@ -133,44 +133,3 @@ pub use crate::share::{FlowControl, Ping, PingPong, Pong, RecvStream, SendStream
133133

134134
#[cfg(feature = "unstable")]
135135
pub use codec::{Codec, SendError, UserError};
136-
137-
use std::task::Poll;
138-
139-
// TODO: Get rid of this trait once https://github.com/rust-lang/rust/pull/63512
140-
// is stabilized.
141-
trait PollExt<T, E> {
142-
/// Changes the success value of this `Poll` with the closure provided.
143-
fn map_ok_<U, F>(self, f: F) -> Poll<Option<Result<U, E>>>
144-
where
145-
F: FnOnce(T) -> U;
146-
/// Changes the error value of this `Poll` with the closure provided.
147-
fn map_err_<U, F>(self, f: F) -> Poll<Option<Result<T, U>>>
148-
where
149-
F: FnOnce(E) -> U;
150-
}
151-
152-
impl<T, E> PollExt<T, E> for Poll<Option<Result<T, E>>> {
153-
fn map_ok_<U, F>(self, f: F) -> Poll<Option<Result<U, E>>>
154-
where
155-
F: FnOnce(T) -> U,
156-
{
157-
match self {
158-
Poll::Ready(Some(Ok(t))) => Poll::Ready(Some(Ok(f(t)))),
159-
Poll::Ready(Some(Err(e))) => Poll::Ready(Some(Err(e))),
160-
Poll::Ready(None) => Poll::Ready(None),
161-
Poll::Pending => Poll::Pending,
162-
}
163-
}
164-
165-
fn map_err_<U, F>(self, f: F) -> Poll<Option<Result<T, U>>>
166-
where
167-
F: FnOnce(E) -> U,
168-
{
169-
match self {
170-
Poll::Ready(Some(Ok(t))) => Poll::Ready(Some(Ok(t))),
171-
Poll::Ready(Some(Err(e))) => Poll::Ready(Some(Err(f(e)))),
172-
Poll::Ready(None) => Poll::Ready(None),
173-
Poll::Pending => Poll::Pending,
174-
}
175-
}
176-
}

src/proto/streams/streams.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use http::{HeaderMap, Request, Response};
1212
use std::task::{Context, Poll, Waker};
1313
use tokio::io::AsyncWrite;
1414

15-
use crate::PollExt;
1615
use std::sync::{Arc, Mutex};
1716
use std::{fmt, io};
1817

@@ -1282,7 +1281,7 @@ impl OpaqueStreamRef {
12821281
me.actions
12831282
.recv
12841283
.poll_pushed(cx, &mut stream)
1285-
.map_ok_(|(h, key)| {
1284+
.map_ok(|(h, key)| {
12861285
me.refs += 1;
12871286
let opaque_ref =
12881287
OpaqueStreamRef::new(self.inner.clone(), &mut me.store.resolve(key));

src/share.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use crate::proto::{self, WindowSize};
55
use bytes::{Buf, Bytes};
66
use http::HeaderMap;
77

8-
use crate::PollExt;
98
use std::fmt;
109
#[cfg(feature = "stream")]
1110
use std::pin::Pin;
@@ -307,8 +306,8 @@ impl<B: Buf> SendStream<B> {
307306
pub fn poll_capacity(&mut self, cx: &mut Context) -> Poll<Option<Result<usize, crate::Error>>> {
308307
self.inner
309308
.poll_capacity(cx)
310-
.map_ok_(|w| w as usize)
311-
.map_err_(Into::into)
309+
.map_ok(|w| w as usize)
310+
.map_err(Into::into)
312311
}
313312

314313
/// Sends a single data frame to the remote peer.
@@ -403,7 +402,7 @@ impl RecvStream {
403402

404403
/// Poll for the next data frame.
405404
pub fn poll_data(&mut self, cx: &mut Context<'_>) -> Poll<Option<Result<Bytes, crate::Error>>> {
406-
self.inner.inner.poll_data(cx).map_err_(Into::into)
405+
self.inner.inner.poll_data(cx).map_err(Into::into)
407406
}
408407

409408
#[doc(hidden)]

0 commit comments

Comments
 (0)