diff --git a/src/client/conn.rs b/src/client/conn.rs index d030c27a..b4b3330d 100644 --- a/src/client/conn.rs +++ b/src/client/conn.rs @@ -238,12 +238,11 @@ where } } - //TODO: replace with `impl Future` when stable - pub(crate) fn send_request_retryable(&mut self, req: Request) -> Box, Error=(::Error, Option>)> + Send> + pub(crate) fn send_request_retryable(&mut self, req: Request) -> impl Future, Error = (::Error, Option>)> + Send where B: Send, { - let inner = match self.dispatch.try_send(req) { + match self.dispatch.try_send(req) { Ok(rx) => { Either::A(rx.then(move |res| { match res { @@ -259,8 +258,7 @@ where let err = ::Error::new_canceled(Some("connection was not ready")); Either::B(future::err((err, Some(req)))) } - }; - Box::new(inner) + } } } @@ -300,12 +298,11 @@ impl Http2SendRequest where B: Payload + 'static, { - //TODO: replace with `impl Future` when stable - pub(super) fn send_request_retryable(&mut self, req: Request) -> Box, Error=(::Error, Option>)> + Send> + pub(super) fn send_request_retryable(&mut self, req: Request) -> impl Future, Error=(::Error, Option>)> + Send where B: Send, { - let inner = match self.dispatch.try_send(req) { + match self.dispatch.try_send(req) { Ok(rx) => { Either::A(rx.then(move |res| { match res { @@ -321,8 +318,7 @@ where let err = ::Error::new_canceled(Some("connection was not ready")); Either::B(future::err((err, Some(req)))) } - }; - Box::new(inner) + } } } diff --git a/src/client/mod.rs b/src/client/mod.rs index ebc538b8..3a5a7f29 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -547,6 +547,12 @@ struct RetryableSendRequest { uri: Uri, } +impl fmt::Debug for RetryableSendRequest { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.pad("Future") + } +} + impl Future for RetryableSendRequest where C: Connect + 'static, @@ -617,14 +623,13 @@ impl PoolClient { } impl PoolClient { - //TODO: replace with `impl Future` when stable - fn send_request_retryable(&mut self, req: Request) -> Box, Error=(::Error, Option>)> + Send> + fn send_request_retryable(&mut self, req: Request) -> impl Future, Error = (::Error, Option>)> + Send where B: Send, { match self.tx { - PoolTx::Http1(ref mut tx) => tx.send_request_retryable(req), - PoolTx::Http2(ref mut tx) => tx.send_request_retryable(req), + PoolTx::Http1(ref mut tx) => Either::A(tx.send_request_retryable(req)), + PoolTx::Http2(ref mut tx) => Either::B(tx.send_request_retryable(req)), } } }