diff --git a/src/routes.rs b/src/routes.rs index d7b834a..8406cb0 100644 --- a/src/routes.rs +++ b/src/routes.rs @@ -53,9 +53,9 @@ impl LimitPolicy { pub fn get_count(&self) -> u64 { match self { LimitPolicy::NONE => 0, - LimitPolicy::SUCCESS(n) => n.clone(), - LimitPolicy::FAILURE(n) => n.clone(), - LimitPolicy::ANY(n) => n.clone(), + LimitPolicy::SUCCESS(n) => *n, + LimitPolicy::FAILURE(n) => *n, + LimitPolicy::ANY(n) => *n, } } } diff --git a/src/server.rs b/src/server.rs index 0b7085b..089fa03 100644 --- a/src/server.rs +++ b/src/server.rs @@ -45,7 +45,7 @@ impl<'a> Stream for LimitedStream let res = Pin::new(self.stream.as_mut()).poll_next(cx); if let Poll::Ready(Some(Ok(d))) = &res { - self.already_read = self.already_read + d.len(); + self.already_read += d.len(); } res @@ -128,13 +128,13 @@ impl FromRequest for CustomRequest { }; // Parse body arguments (following the pattern key1=value1&key2=value2) - if body_str.len() > 0 { - for v in body_str.split("&") { - if v.len() == 0 { + if !body_str.is_empty() { + for v in body_str.split('&') { + if v.is_empty() { continue; } - let args: Vec<&str> = v.split("=").collect(); + let args: Vec<&str> = v.split('=').collect(); if args.len() != 2 { return Err(actix_web::error::ErrorBadRequest(format!("{} is invalid!", args[0])));