diff options
| author | Santo Cariotti <santo@dcariotti.me> | 2022-09-10 15:59:26 +0000 |
|---|---|---|
| committer | Santo Cariotti <santo@dcariotti.me> | 2022-09-10 16:01:17 +0000 |
| commit | 63b49b0876457a1bce9405a571f3c9b97a270fb4 (patch) | |
| tree | d3fbf0429f9f7cd12bca7a3e03b20efc9cba7dd9 /src | |
| parent | 25f225a0ddbd7cce9498c1c8c812ad61288599f2 (diff) | |
style: clippy
Diffstat (limited to 'src')
| -rw-r--r-- | src/files.rs | 10 | ||||
| -rw-r--r-- | src/routes/model.rs | 4 |
2 files changed, 4 insertions, 10 deletions
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::<f32>() * 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); } diff --git a/src/routes/model.rs b/src/routes/model.rs index 66f8ec6..3d5084c 100644 --- a/src/routes/model.rs +++ b/src/routes/model.rs @@ -77,8 +77,6 @@ async fn upload_model_file( Ok(saved_file) => { return Ok(format!("Uploaded {}", saved_file)); } - Err(e) => { - return Err(e); - } + Err(e) => Err(e), } } |
