From 2881354c90a63daf95a2dce0c87a5507b2336f2f Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Wed, 25 Aug 2021 11:30:34 +0200 Subject: [PATCH] Fix more clippy warnings --- src/async_impl/request.rs | 6 +++--- src/connect.rs | 4 ++-- src/wasm/client.rs | 5 ++--- src/wasm/request.rs | 5 ++--- tests/support/mod.rs | 2 +- tests/timeouts.rs | 4 ++-- 6 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/async_impl/request.rs b/src/async_impl/request.rs index 8e936cb..cb0b5d3 100644 --- a/src/async_impl/request.rs +++ b/src/async_impl/request.rs @@ -130,13 +130,13 @@ impl Request { /// `None` is returned if the request can not be cloned, i.e. if the body is a stream. pub fn try_clone(&self) -> Option { let body = match self.body.as_ref() { - Some(ref body) => Some(body.try_clone()?), + Some(body) => Some(body.try_clone()?), None => None, }; let mut req = Request::new(self.method().clone(), self.url().clone()); *req.timeout_mut() = self.timeout().cloned(); *req.headers_mut() = self.headers().clone(); - *req.version_mut() = self.version().clone(); + *req.version_mut() = self.version(); req.body = body; Some(req) } @@ -565,7 +565,7 @@ where headers, body: Some(body.into()), timeout: None, - version: version, + version, }) } } diff --git a/src/connect.rs b/src/connect.rs index 375d402..7662a47 100644 --- a/src/connect.rs +++ b/src/connect.rs @@ -464,7 +464,7 @@ impl Connector { .await?; let tls_connector = tokio_native_tls::TlsConnector::from(tls.clone()); let io = tls_connector - .connect(&host.ok_or("no host in url")?, tunneled) + .connect(host.ok_or("no host in url")?, tunneled) .await?; return Ok(Conn { inner: self.verbose.wrap(NativeTlsConn { inner: io }), @@ -1198,7 +1198,7 @@ mod tests { use tokio::net::TcpStream; use tokio::runtime; - static TUNNEL_UA: &'static str = "tunnel-test/x.y"; + static TUNNEL_UA: &str = "tunnel-test/x.y"; static TUNNEL_OK: &[u8] = b"\ HTTP/1.1 200 OK\r\n\ \r\n\ diff --git a/src/wasm/client.rs b/src/wasm/client.rs index bf258c7..bd8d762 100644 --- a/src/wasm/client.rs +++ b/src/wasm/client.rs @@ -17,8 +17,7 @@ fn js_fetch(req: &web_sys::Request) -> Promise { use wasm_bindgen::{JsCast, JsValue}; let global = js_sys::global(); - if let Some(true) = - js_sys::Reflect::has(&global, &JsValue::from_str("ServiceWorkerGlobalScope")).ok() + if let Ok(true) = js_sys::Reflect::has(&global, &JsValue::from_str("ServiceWorkerGlobalScope")) { global .unchecked_into::() @@ -213,7 +212,7 @@ async fn fetch(req: Request) -> crate::Result { if let Some(body) = req.body() { if !body.is_empty() { - init.body(Some(&body.to_js_value()?.as_ref().as_ref())); + init.body(Some(body.to_js_value()?.as_ref())); } } diff --git a/src/wasm/request.rs b/src/wasm/request.rs index d45a3a9..a939cc7 100644 --- a/src/wasm/request.rs +++ b/src/wasm/request.rs @@ -6,7 +6,6 @@ use http::{request::Parts, Method, Request as HttpRequest}; use serde::Serialize; #[cfg(feature = "json")] use serde_json; -use serde_urlencoded; use url::Url; use web_sys::RequestCredentials; @@ -96,7 +95,7 @@ impl Request { /// None is returned if a body is which can not be cloned. pub fn try_clone(&self) -> Option { let body = match self.body.as_ref() { - Some(ref body) => Some(body.try_clone()?), + Some(body) => Some(body.try_clone()?), None => None, }; @@ -106,7 +105,7 @@ impl Request { headers: self.headers.clone(), body, cors: self.cors, - credentials: self.credentials.clone(), + credentials: self.credentials, }) } } diff --git a/tests/support/mod.rs b/tests/support/mod.rs index 6434fb6..cef2170 100644 --- a/tests/support/mod.rs +++ b/tests/support/mod.rs @@ -2,5 +2,5 @@ pub mod server; // TODO: remove once done converting to new support server? #[allow(unused)] -pub static DEFAULT_USER_AGENT: &'static str = +pub static DEFAULT_USER_AGENT: &str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")); diff --git a/tests/timeouts.rs b/tests/timeouts.rs index 35b105e..d2c7289 100644 --- a/tests/timeouts.rs +++ b/tests/timeouts.rs @@ -73,10 +73,10 @@ async fn connect_timeout() { .build() .unwrap(); - let url = format!("http://10.255.255.1:81/slow"); + let url = "http://10.255.255.1:81/slow"; let res = client - .get(&url) + .get(url) .timeout(Duration::from_millis(1000)) .send() .await;