summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-05-22 11:36:01 +0200
committerMatthias Beyer <mail@beyermatthias.de>2020-05-22 11:36:01 +0200
commitca29a2af765e3a70dc4ce52240bb4385820bfda9 (patch)
tree8a5df3c3c8a300f169d9b02fb46155fbe0e2851c
parent49474dbbb5eb6e80728918480e20df47d74082e3 (diff)
Remove match by function chaining
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--src/main.rs8
1 files changed, 1 insertions, 7 deletions
diff --git a/src/main.rs b/src/main.rs
index cb66424..d12e2ce 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -231,13 +231,7 @@ async fn on_get(req: Request<Body>) -> Result<Response<Body>, Box<dyn Error>> {
async fn on_put(req: Request<Body>) -> Result<Response<Body>, Infallible> {
let guess = mime_guess::from_path(req.uri().path()).first();
- let ext = match guess {
- Some(g) => match mime_guess::get_mime_extensions(&g) {
- Some(mimes) => Some(mimes[0]),
- None => None,
- },
- None => None,
- };
+ let ext = guess.and_then(|g| mime_guess::get_mime_extensions(&g).map(|m| m[0]));
let fileres = create_random_file(&CONFIG.data);
let (mut file, name) = match fileres {