Fix clippy warnings (#981)

* refactor: fix clippy warnings

* refactor: fix redundant_closure

* refactor: fix collapsible if

* refactor: remove unnecessary_unwrap
This commit is contained in:
Takayuki Maeda
2020-07-28 01:02:47 +09:00
committed by GitHub
parent c78aa50d4c
commit 1e6957a4ac
6 changed files with 11 additions and 20 deletions

View File

@@ -222,7 +222,7 @@ impl HttpBody for ImplStream {
if bytes.is_empty() {
None
} else {
Some(Ok(std::mem::replace(bytes, Bytes::new()).into()))
Some(Ok(std::mem::replace(bytes, Bytes::new())))
}
}
};

View File

@@ -1021,14 +1021,10 @@ impl Client {
let accept_encoding = self.inner.accepts.as_str();
if accept_encoding.is_some()
&& !headers.contains_key(ACCEPT_ENCODING)
&& !headers.contains_key(RANGE)
{
headers.insert(
ACCEPT_ENCODING,
HeaderValue::from_static(accept_encoding.unwrap()),
);
if let Some(accept_encoding) = accept_encoding {
if !headers.contains_key(ACCEPT_ENCODING) && !headers.contains_key(RANGE) {
headers.insert(ACCEPT_ENCODING, HeaderValue::from_static(accept_encoding));
}
}
let uri = expect_uri(&url);
@@ -1045,13 +1041,13 @@ impl Client {
let mut req = hyper::Request::builder()
.method(method.clone())
.uri(uri.clone())
.uri(uri)
.body(body.into_stream())
.expect("valid request parts");
let timeout = timeout
.or(self.inner.request_timeout)
.map(|dur| tokio::time::delay_for(dur));
.map(tokio::time::delay_for);
*req.headers_mut() = headers.clone();

View File

@@ -225,7 +225,7 @@ impl Stream for Decoder {
}
Poll::Pending => return Poll::Pending,
},
Inner::PlainText(ref mut body) => return Pin::new(body).poll_next(cx),
Inner::PlainText(ref mut body) => Pin::new(body).poll_next(cx),
#[cfg(feature = "gzip")]
Inner::Gzip(ref mut decoder) => {
return match futures_core::ready!(Pin::new(decoder).poll_next(cx)) {
@@ -242,7 +242,7 @@ impl Stream for Decoder {
None => Poll::Ready(None),
};
}
};
}
}
}

View File

@@ -4,12 +4,10 @@ use std::future::Future;
use std::io::Write;
use std::time::Duration;
use base64;
use base64::write::EncoderWriter as Base64Encoder;
use serde::Serialize;
#[cfg(feature = "json")]
use serde_json;
use serde_urlencoded;
use super::body::Body;
use super::client::{Client, Pending};

View File

@@ -5,7 +5,6 @@ use std::net::SocketAddr;
use bytes::Bytes;
use encoding_rs::{Encoding, UTF_8};
use futures_util::stream::StreamExt;
use http;
use hyper::client::connect::HttpInfo;
use hyper::{HeaderMap, StatusCode, Version};
use mime::Mime;

View File

@@ -706,10 +706,8 @@ fn get_from_environment() -> SystemProxyMap {
let mut proxies = HashMap::new();
if is_cgi() {
if log::log_enabled!(log::Level::Warn) {
if env::var_os("HTTP_PROXY").is_some() {
log::warn!("HTTP_PROXY environment variable ignored in CGI");
}
if log::log_enabled!(log::Level::Warn) && env::var_os("HTTP_PROXY").is_some() {
log::warn!("HTTP_PROXY environment variable ignored in CGI");
}
} else if !insert_from_env(&mut proxies, "http", "HTTP_PROXY") {
insert_from_env(&mut proxies, "http", "http_proxy");