perf(client): replace usage of Box<Trait> with impl Trait
This commit is contained in:
		
				
					committed by
					
						 Sean McArthur
						Sean McArthur
					
				
			
			
				
	
			
			
			
						parent
						
							26f3a5ed31
						
					
				
				
					commit
					4290b8bba4
				
			| @@ -238,12 +238,11 @@ where | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     //TODO: replace with `impl Future` when stable |     pub(crate) fn send_request_retryable(&mut self, req: Request<B>) -> impl Future<Item = Response<Body>, Error = (::Error, Option<Request<B>>)> + Send | ||||||
|     pub(crate) fn send_request_retryable(&mut self, req: Request<B>) -> Box<Future<Item=Response<Body>, Error=(::Error, Option<Request<B>>)> + Send> |  | ||||||
|     where |     where | ||||||
|         B: Send, |         B: Send, | ||||||
|     { |     { | ||||||
|         let inner = match self.dispatch.try_send(req) { |         match self.dispatch.try_send(req) { | ||||||
|             Ok(rx) => { |             Ok(rx) => { | ||||||
|                 Either::A(rx.then(move |res| { |                 Either::A(rx.then(move |res| { | ||||||
|                     match res { |                     match res { | ||||||
| @@ -259,8 +258,7 @@ where | |||||||
|                 let err = ::Error::new_canceled(Some("connection was not ready")); |                 let err = ::Error::new_canceled(Some("connection was not ready")); | ||||||
|                 Either::B(future::err((err, Some(req)))) |                 Either::B(future::err((err, Some(req)))) | ||||||
|             } |             } | ||||||
|         }; |         } | ||||||
|         Box::new(inner) |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -300,12 +298,11 @@ impl<B> Http2SendRequest<B> | |||||||
| where | where | ||||||
|     B: Payload + 'static, |     B: Payload + 'static, | ||||||
| { | { | ||||||
|     //TODO: replace with `impl Future` when stable |     pub(super) fn send_request_retryable(&mut self, req: Request<B>) -> impl Future<Item=Response<Body>, Error=(::Error, Option<Request<B>>)> + Send | ||||||
|     pub(super) fn send_request_retryable(&mut self, req: Request<B>) -> Box<Future<Item=Response<Body>, Error=(::Error, Option<Request<B>>)> + Send> |  | ||||||
|     where |     where | ||||||
|         B: Send, |         B: Send, | ||||||
|     { |     { | ||||||
|         let inner = match self.dispatch.try_send(req) { |         match self.dispatch.try_send(req) { | ||||||
|             Ok(rx) => { |             Ok(rx) => { | ||||||
|                 Either::A(rx.then(move |res| { |                 Either::A(rx.then(move |res| { | ||||||
|                     match res { |                     match res { | ||||||
| @@ -321,8 +318,7 @@ where | |||||||
|                 let err = ::Error::new_canceled(Some("connection was not ready")); |                 let err = ::Error::new_canceled(Some("connection was not ready")); | ||||||
|                 Either::B(future::err((err, Some(req)))) |                 Either::B(future::err((err, Some(req)))) | ||||||
|             } |             } | ||||||
|         }; |         } | ||||||
|         Box::new(inner) |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -547,6 +547,12 @@ struct RetryableSendRequest<C, B> { | |||||||
|     uri: Uri, |     uri: Uri, | ||||||
| } | } | ||||||
|  |  | ||||||
|  | impl<C, B> fmt::Debug for RetryableSendRequest<C, B> { | ||||||
|  |     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||||||
|  |         f.pad("Future<Response>") | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
| impl<C, B> Future for RetryableSendRequest<C, B> | impl<C, B> Future for RetryableSendRequest<C, B> | ||||||
| where | where | ||||||
|     C: Connect + 'static, |     C: Connect + 'static, | ||||||
| @@ -617,14 +623,13 @@ impl<B> PoolClient<B> { | |||||||
| } | } | ||||||
|  |  | ||||||
| impl<B: Payload + 'static> PoolClient<B> { | impl<B: Payload + 'static> PoolClient<B> { | ||||||
|     //TODO: replace with `impl Future` when stable |     fn send_request_retryable(&mut self, req: Request<B>) -> impl Future<Item = Response<Body>, Error = (::Error, Option<Request<B>>)> + Send | ||||||
|     fn send_request_retryable(&mut self, req: Request<B>) -> Box<Future<Item=Response<Body>, Error=(::Error, Option<Request<B>>)> + Send> |  | ||||||
|     where |     where | ||||||
|         B: Send, |         B: Send, | ||||||
|     { |     { | ||||||
|         match self.tx { |         match self.tx { | ||||||
|             PoolTx::Http1(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) => tx.send_request_retryable(req), |             PoolTx::Http2(ref mut tx) => Either::B(tx.send_request_retryable(req)), | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user