1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-11-22 13:29:21 +00:00

Improve code readability

This commit is contained in:
Pierre HUBERT 2022-03-17 18:13:47 +01:00
parent 68055712d9
commit 5c938dccd1
2 changed files with 8 additions and 8 deletions

View File

@ -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,
}
}
}

View File

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