style(lib): address most clippy lints
This commit is contained in:
		
				
					committed by
					
						 Sean McArthur
						Sean McArthur
					
				
			
			
				
	
			
			
			
						parent
						
							0f13719873
						
					
				
				
					commit
					0eaf304644
				
			| @@ -345,8 +345,8 @@ where | ||||
|         }; | ||||
|  | ||||
|         Parts { | ||||
|             io: io, | ||||
|             read_buf: read_buf, | ||||
|             io, | ||||
|             read_buf, | ||||
|             _inner: (), | ||||
|         } | ||||
|     } | ||||
| @@ -363,9 +363,9 @@ where | ||||
|     /// and [`try_ready!`](https://docs.rs/futures/0.1.25/futures/macro.try_ready.html) | ||||
|     /// to work with this function; or use the `without_shutdown` wrapper. | ||||
|     pub fn poll_without_shutdown(&mut self, cx: &mut task::Context<'_>) -> Poll<crate::Result<()>> { | ||||
|         match self.inner.as_mut().expect("already upgraded") { | ||||
|             &mut ProtoClient::H1(ref mut h1) => h1.poll_without_shutdown(cx), | ||||
|             &mut ProtoClient::H2(ref mut h2) => Pin::new(h2).poll(cx).map_ok(|_| ()), | ||||
|         match *self.inner.as_mut().expect("already upgraded") { | ||||
|             ProtoClient::H1(ref mut h1) => h1.poll_without_shutdown(cx), | ||||
|             ProtoClient::H2(ref mut h2) => Pin::new(h2).poll(cx).map_ok(|_| ()), | ||||
|         } | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -542,7 +542,7 @@ impl ConnectingTcpRemote { | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         return Err(err.take().expect("missing connect error")); | ||||
|         Err(err.take().expect("missing connect error")) | ||||
|     } | ||||
| } | ||||
|  | ||||
| @@ -552,9 +552,9 @@ fn connect( | ||||
|     reuse_address: bool, | ||||
|     connect_timeout: Option<Duration>, | ||||
| ) -> io::Result<impl Future<Output = io::Result<TcpStream>>> { | ||||
|     let builder = match addr { | ||||
|         &SocketAddr::V4(_) => TcpBuilder::new_v4()?, | ||||
|         &SocketAddr::V6(_) => TcpBuilder::new_v6()?, | ||||
|     let builder = match *addr { | ||||
|         SocketAddr::V4(_) => TcpBuilder::new_v4()?, | ||||
|         SocketAddr::V6(_) => TcpBuilder::new_v6()?, | ||||
|     }; | ||||
|  | ||||
|     if reuse_address { | ||||
| @@ -566,9 +566,9 @@ fn connect( | ||||
|         builder.bind(SocketAddr::new(local_addr.clone(), 0))?; | ||||
|     } else if cfg!(windows) { | ||||
|         // Windows requires a socket be bound before calling connect | ||||
|         let any: SocketAddr = match addr { | ||||
|             &SocketAddr::V4(_) => ([0, 0, 0, 0], 0).into(), | ||||
|             &SocketAddr::V6(_) => ([0, 0, 0, 0, 0, 0, 0, 0], 0).into(), | ||||
|         let any: SocketAddr = match *addr { | ||||
|             SocketAddr::V4(_) => ([0, 0, 0, 0], 0).into(), | ||||
|             SocketAddr::V6(_) => ([0, 0, 0, 0, 0, 0, 0, 0], 0).into(), | ||||
|         }; | ||||
|         builder.bind(any)?; | ||||
|     } | ||||
| @@ -619,7 +619,7 @@ impl ConnectingTcp { | ||||
|                         } | ||||
|                     }; | ||||
|  | ||||
|                 if let Err(_) = result { | ||||
|                 if result.is_err() { | ||||
|                     // Fallback to the remaining future (could be preferred or fallback) | ||||
|                     // if we get an error | ||||
|                     future.await | ||||
|   | ||||
| @@ -12,13 +12,10 @@ pub fn channel<T, U>() -> (Sender<T, U>, Receiver<T, U>) { | ||||
|     let (giver, taker) = want::new(); | ||||
|     let tx = Sender { | ||||
|         buffered_once: false, | ||||
|         giver: giver, | ||||
|         giver, | ||||
|         inner: tx, | ||||
|     }; | ||||
|     let rx = Receiver { | ||||
|         inner: rx, | ||||
|         taker: taker, | ||||
|     }; | ||||
|     let rx = Receiver { inner: rx, taker }; | ||||
|     (tx, rx) | ||||
| } | ||||
|  | ||||
| @@ -183,7 +180,7 @@ struct Envelope<T, U>(Option<(T, Callback<T, U>)>); | ||||
| impl<T, U> Drop for Envelope<T, U> { | ||||
|     fn drop(&mut self) { | ||||
|         if let Some((val, cb)) = self.0.take() { | ||||
|             let _ = cb.send(Err(( | ||||
|             cb.send(Err(( | ||||
|                 crate::Error::new_canceled().with("connection closed"), | ||||
|                 Some(val), | ||||
|             ))); | ||||
|   | ||||
| @@ -210,7 +210,7 @@ where | ||||
|     /// # fn main() {} | ||||
|     /// ``` | ||||
|     pub fn request(&self, mut req: Request<B>) -> ResponseFuture { | ||||
|         let is_http_connect = req.method() == &Method::CONNECT; | ||||
|         let is_http_connect = req.method() == Method::CONNECT; | ||||
|         match req.version() { | ||||
|             Version::HTTP_11 => (), | ||||
|             Version::HTTP_10 => { | ||||
| @@ -237,7 +237,7 @@ where | ||||
|             } | ||||
|         }; | ||||
|  | ||||
|         let pool_key = Arc::new(domain.to_string()); | ||||
|         let pool_key = Arc::new(domain); | ||||
|         ResponseFuture::new(Box::new(self.retryably_send_request(req, pool_key))) | ||||
|     } | ||||
|  | ||||
| @@ -302,14 +302,14 @@ where | ||||
|                 } | ||||
|  | ||||
|                 // CONNECT always sends authority-form, so check it first... | ||||
|                 if req.method() == &Method::CONNECT { | ||||
|                 if req.method() == Method::CONNECT { | ||||
|                     authority_form(req.uri_mut()); | ||||
|                 } else if pooled.conn_info.is_proxied { | ||||
|                     absolute_form(req.uri_mut()); | ||||
|                 } else { | ||||
|                     origin_form(req.uri_mut()); | ||||
|                 }; | ||||
|             } else if req.method() == &Method::CONNECT { | ||||
|             } else if req.method() == Method::CONNECT { | ||||
|                 debug!("client does not support CONNECT requests over HTTP2"); | ||||
|                 return Either::Left(future::err(ClientError::Normal( | ||||
|                     crate::Error::new_user_unsupported_request_method(), | ||||
| @@ -422,7 +422,7 @@ where | ||||
|                         }); | ||||
|                     // An execute error here isn't important, we're just trying | ||||
|                     // to prevent a waste of a socket... | ||||
|                     let _ = executor.execute(bg); | ||||
|                     executor.execute(bg); | ||||
|                 } | ||||
|                 Either::Left(future::ok(checked_out)) | ||||
|             } | ||||
|   | ||||
| @@ -352,7 +352,7 @@ impl<T: Poolable> PoolInner<T> { | ||||
|             Some(value) => { | ||||
|                 // borrow-check scope... | ||||
|                 { | ||||
|                     let idle_list = self.idle.entry(key.clone()).or_insert(Vec::new()); | ||||
|                     let idle_list = self.idle.entry(key.clone()).or_insert_with(Vec::new); | ||||
|                     if self.max_idle_per_host <= idle_list.len() { | ||||
|                         trace!("max idle per host for {:?}, dropping connection", key); | ||||
|                         return; | ||||
| @@ -360,7 +360,7 @@ impl<T: Poolable> PoolInner<T> { | ||||
|  | ||||
|                     debug!("pooling idle connection for {:?}", key); | ||||
|                     idle_list.push(Idle { | ||||
|                         value: value, | ||||
|                         value, | ||||
|                         idle_at: Instant::now(), | ||||
|                     }); | ||||
|                 } | ||||
| @@ -610,7 +610,7 @@ impl<T: Poolable> Checkout<T> { | ||||
|                 inner | ||||
|                     .waiters | ||||
|                     .entry(self.key.clone()) | ||||
|                     .or_insert(VecDeque::new()) | ||||
|                     .or_insert_with(VecDeque::new) | ||||
|                     .push_back(tx); | ||||
|  | ||||
|                 // register the waker with this oneshot | ||||
|   | ||||
		Reference in New Issue
	
	Block a user