From 218e8e595fa0e4cef044e167a73eac742639c286 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Mon, 31 Jan 2022 16:34:26 +0000 Subject: [PATCH] clippy --- actix-http/src/config.rs | 14 ++------------ actix-http/src/h1/dispatcher.rs | 20 +++++++++++++------- actix-http/src/keep_alive.rs | 2 +- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/actix-http/src/config.rs b/actix-http/src/config.rs index 0b9383a84..aa05d6aba 100644 --- a/actix-http/src/config.rs +++ b/actix-http/src/config.rs @@ -91,23 +91,13 @@ impl ServiceConfig { /// Returns `None` if this `ServiceConfig was` constructed with `client_request_timeout: 0`. pub fn client_request_deadline(&self) -> Option { let timeout = self.0.client_request_timeout; - - if timeout != Duration::ZERO { - Some(self.now() + timeout) - } else { - None - } + (timeout != Duration::ZERO).then(|| self.now() + timeout) } /// Creates a time object representing the deadline for the client to disconnect. pub fn client_disconnect_deadline(&self) -> Option { let timeout = self.0.client_disconnect_timeout; - - if timeout != Duration::ZERO { - Some(self.now() + timeout) - } else { - None - } + (timeout != Duration::ZERO).then(|| self.now() + timeout) } pub(crate) fn now(&self) -> Instant { diff --git a/actix-http/src/h1/dispatcher.rs b/actix-http/src/h1/dispatcher.rs index 1fa357713..f21433e57 100644 --- a/actix-http/src/h1/dispatcher.rs +++ b/actix-http/src/h1/dispatcher.rs @@ -207,13 +207,19 @@ where { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::None => write!(f, "None"), - Self::ExpectCall { .. } => f.debug_struct("ExpectCall").finish_non_exhaustive(), - Self::ServiceCall { .. } => f.debug_struct("ServiceCall").finish_non_exhaustive(), - Self::SendPayload { .. } => f.debug_struct("SendPayload").finish_non_exhaustive(), - Self::SendErrorPayload { .. } => { - f.debug_struct("SendErrorPayload").finish_non_exhaustive() + Self::None => write!(f, "State::None"), + Self::ExpectCall { .. } => { + f.debug_struct("State::ExpectCall").finish_non_exhaustive() } + Self::ServiceCall { .. } => { + f.debug_struct("State::ServiceCall").finish_non_exhaustive() + } + Self::SendPayload { .. } => { + f.debug_struct("State::SendPayload").finish_non_exhaustive() + } + Self::SendErrorPayload { .. } => f + .debug_struct("State::SendErrorPayload") + .finish_non_exhaustive(), } } } @@ -771,7 +777,7 @@ where Ok(None) => break, Err(ParseError::Io(err)) => { - log::trace!("io error: {}", &err); + log::trace!("I/O error: {}", &err); self.as_mut().client_disconnected(); this = self.as_mut().project(); *this.error = Some(DispatchError::Io(err)); diff --git a/actix-http/src/keep_alive.rs b/actix-http/src/keep_alive.rs index 136bab04c..27161614d 100644 --- a/actix-http/src/keep_alive.rs +++ b/actix-http/src/keep_alive.rs @@ -21,7 +21,7 @@ pub enum KeepAlive { impl KeepAlive { pub(crate) fn enabled(&self) -> bool { - matches!(self, Self::Timeout(_) | Self::Os) + !matches!(self, Self::Disabled) } pub(crate) fn duration(&self) -> Option {