fix clippy warning on nightly

This commit is contained in:
fakeshadow 2021-03-19 12:00:06 +08:00
parent 81942d31d6
commit 7072cde23c
10 changed files with 23 additions and 46 deletions

View File

@ -325,7 +325,7 @@ where
} }
} }
const H2_UNREACHABLE_WRITE: &'static str = "H2Connection can not impl AsyncWrite trait"; const H2_UNREACHABLE_WRITE: &str = "H2Connection can not impl AsyncWrite trait";
impl<A, B> AsyncWrite for Connection<A, B> impl<A, B> AsyncWrite for Connection<A, B>
where where

View File

@ -126,9 +126,7 @@ impl ServiceConfig {
pub fn client_timer(&self) -> Option<Sleep> { pub fn client_timer(&self) -> Option<Sleep> {
let delay_time = self.0.client_timeout; let delay_time = self.0.client_timeout;
if delay_time != 0 { if delay_time != 0 {
Some(sleep_until( Some(sleep_until(self.now() + Duration::from_millis(delay_time)))
self.0.date_service.now() + Duration::from_millis(delay_time),
))
} else { } else {
None None
} }
@ -138,7 +136,7 @@ impl ServiceConfig {
pub fn client_timer_expire(&self) -> Option<Instant> { pub fn client_timer_expire(&self) -> Option<Instant> {
let delay = self.0.client_timeout; let delay = self.0.client_timeout;
if delay != 0 { if delay != 0 {
Some(self.0.date_service.now() + Duration::from_millis(delay)) Some(self.now() + Duration::from_millis(delay))
} else { } else {
None None
} }
@ -148,7 +146,7 @@ impl ServiceConfig {
pub fn client_disconnect_timer(&self) -> Option<Instant> { pub fn client_disconnect_timer(&self) -> Option<Instant> {
let delay = self.0.client_disconnect; let delay = self.0.client_disconnect;
if delay != 0 { if delay != 0 {
Some(self.0.date_service.now() + Duration::from_millis(delay)) Some(self.now() + Duration::from_millis(delay))
} else { } else {
None None
} }
@ -157,20 +155,12 @@ impl ServiceConfig {
#[inline] #[inline]
/// Return keep-alive timer delay is configured. /// Return keep-alive timer delay is configured.
pub fn keep_alive_timer(&self) -> Option<Sleep> { pub fn keep_alive_timer(&self) -> Option<Sleep> {
if let Some(ka) = self.0.keep_alive { self.keep_alive().map(|ka| sleep_until(self.now() + ka))
Some(sleep_until(self.0.date_service.now() + ka))
} else {
None
}
} }
/// Keep-alive expire time /// Keep-alive expire time
pub fn keep_alive_expire(&self) -> Option<Instant> { pub fn keep_alive_expire(&self) -> Option<Instant> {
if let Some(ka) = self.0.keep_alive { self.keep_alive().map(|ka| self.now() + ka)
Some(self.0.date_service.now() + ka)
} else {
None
}
} }
#[inline] #[inline]

View File

@ -648,11 +648,6 @@ where
// go into Some<Pin<&mut Sleep>> branch // go into Some<Pin<&mut Sleep>> branch
this.ka_timer.set(Some(sleep_until(deadline))); this.ka_timer.set(Some(sleep_until(deadline)));
return self.poll_keepalive(cx); return self.poll_keepalive(cx);
} else {
this.flags.insert(Flags::READ_DISCONNECT);
if let Some(mut payload) = this.payload.take() {
payload.set_error(PayloadError::Incomplete(None));
}
} }
} }
} }

View File

@ -127,9 +127,8 @@ impl Display for EntityTag {
impl FromStr for EntityTag { impl FromStr for EntityTag {
type Err = crate::error::ParseError; type Err = crate::error::ParseError;
fn from_str(s: &str) -> Result<EntityTag, crate::error::ParseError> { fn from_str(slice: &str) -> Result<EntityTag, crate::error::ParseError> {
let length: usize = s.len(); let length = slice.len();
let slice = &s[..];
// Early exits if it doesn't terminate in a DQUOTE. // Early exits if it doesn't terminate in a DQUOTE.
if !slice.ends_with('"') || slice.len() < 2 { if !slice.ends_with('"') || slice.len() < 2 {
return Err(crate::error::ParseError::Header); return Err(crate::error::ParseError::Header);

View File

@ -88,9 +88,9 @@ pub fn parse_extended_value(
}; };
Ok(ExtendedValue { Ok(ExtendedValue {
value,
charset, charset,
language_tag, language_tag,
value,
}) })
} }

View File

@ -113,7 +113,7 @@ pub struct AppConfig {
impl AppConfig { impl AppConfig {
pub(crate) fn new(secure: bool, addr: SocketAddr, host: String) -> Self { pub(crate) fn new(secure: bool, addr: SocketAddr, host: String) -> Self {
AppConfig { secure, addr, host } AppConfig { secure, host, addr }
} }
/// Server host name. /// Server host name.

View File

@ -173,11 +173,7 @@ pub mod dev {
impl BodyEncoding for ResponseBuilder { impl BodyEncoding for ResponseBuilder {
fn get_encoding(&self) -> Option<ContentEncoding> { fn get_encoding(&self) -> Option<ContentEncoding> {
if let Some(ref enc) = self.extensions().get::<Enc>() { self.extensions().get::<Enc>().map(|enc| enc.0)
Some(enc.0)
} else {
None
}
} }
fn encoding(&mut self, encoding: ContentEncoding) -> &mut Self { fn encoding(&mut self, encoding: ContentEncoding) -> &mut Self {
@ -188,11 +184,7 @@ pub mod dev {
impl<B> BodyEncoding for Response<B> { impl<B> BodyEncoding for Response<B> {
fn get_encoding(&self) -> Option<ContentEncoding> { fn get_encoding(&self) -> Option<ContentEncoding> {
if let Some(ref enc) = self.extensions().get::<Enc>() { self.extensions().get::<Enc>().map(|enc| enc.0)
Some(enc.0)
} else {
None
}
} }
fn encoding(&mut self, encoding: ContentEncoding) -> &mut Self { fn encoding(&mut self, encoding: ContentEncoding) -> &mut Self {

View File

@ -197,22 +197,23 @@ impl AcceptEncoding {
/// Parse a raw Accept-Encoding header value into an ordered list. /// Parse a raw Accept-Encoding header value into an ordered list.
pub fn parse(raw: &str, encoding: ContentEncoding) -> ContentEncoding { pub fn parse(raw: &str, encoding: ContentEncoding) -> ContentEncoding {
let mut encodings: Vec<_> = raw let mut encodings = raw
.replace(' ', "") .replace(' ', "")
.split(',') .split(',')
.map(|l| AcceptEncoding::new(l)) .map(|l| AcceptEncoding::new(l))
.collect(); .flatten()
.collect::<Vec<_>>();
encodings.sort(); encodings.sort();
for enc in encodings { for enc in encodings {
if let Some(enc) = enc { if encoding == ContentEncoding::Auto {
if encoding == ContentEncoding::Auto { return enc.encoding;
return enc.encoding; } else if encoding == enc.encoding {
} else if encoding == enc.encoding { return encoding;
return encoding;
}
} }
} }
ContentEncoding::Identity ContentEncoding::Identity
} }
} }

View File

@ -449,9 +449,9 @@ impl ServiceFactory<ServiceRequest> for ResourceFactory {
.collect::<Result<Vec<_>, _>>()?; .collect::<Result<Vec<_>, _>>()?;
Ok(ResourceService { Ok(ResourceService {
routes,
app_data, app_data,
default, default,
routes,
}) })
}) })
} }

View File

@ -774,10 +774,10 @@ where
}; };
TestServer { TestServer {
ssl,
addr, addr,
client, client,
system, system,
ssl,
server, server,
} }
} }