diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2020-05-22 11:36:01 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2020-05-22 11:36:01 +0200 |
commit | ca29a2af765e3a70dc4ce52240bb4385820bfda9 (patch) | |
tree | 8a5df3c3c8a300f169d9b02fb46155fbe0e2851c | |
parent | 49474dbbb5eb6e80728918480e20df47d74082e3 (diff) |
Remove match by function chaining
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r-- | src/main.rs | 8 |
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 { |