From 63b49b0876457a1bce9405a571f3c9b97a270fb4 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Sat, 10 Sep 2022 17:59:26 +0200 Subject: style: clippy --- src/files.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/files.rs') diff --git a/src/files.rs b/src/files.rs index fe7265a..b88a5b7 100644 --- a/src/files.rs +++ b/src/files.rs @@ -14,10 +14,7 @@ pub async fn upload( if let Some(file) = multipart.next_field().await.unwrap() { let content_type = file.content_type().unwrap().to_string(); - let index = content_type - .find("/") - .map(|i| i) - .unwrap_or(usize::max_value()); + let index = content_type.find('/').unwrap_or(usize::max_value()); let mut ext_name = "xxx"; if index != usize::max_value() { ext_name = &content_type[index + 1..]; @@ -25,8 +22,7 @@ pub async fn upload( if allowed_extensions .iter() - .position(|&x| x.to_lowercase() == ext_name) - .is_some() + .any(|&x| x.to_lowercase() == ext_name) { let rnd = (random::() * 1000000000 as f32) as i32; @@ -40,7 +36,7 @@ pub async fn upload( } } - if save_filename != "" { + if !save_filename.is_empty() { return Ok(save_filename); } -- cgit v1.2.3-71-g8e6c