Fix more clippy warnings

This commit is contained in:
Jonas Platte
2021-08-25 11:30:34 +02:00
committed by Sean McArthur
parent 4be5ec7ffd
commit 2881354c90
6 changed files with 12 additions and 14 deletions

View File

@@ -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<Request> {
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,
})
}
}

View File

@@ -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\

View File

@@ -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::<web_sys::ServiceWorkerGlobalScope>()
@@ -213,7 +212,7 @@ async fn fetch(req: Request) -> crate::Result<Response> {
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()));
}
}

View File

@@ -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<Request> {
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,
})
}
}

View File

@@ -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"));

View File

@@ -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;