summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-05-22 11:37:45 +0200
committerMatthias Beyer <mail@beyermatthias.de>2020-05-22 11:37:45 +0200
commitf904eb2e98a30865207f954184b15b195f41aefc (patch)
treef64118527b5d17aaa087301b788dfe4dd7701a20
parentca29a2af765e3a70dc4ce52240bb4385820bfda9 (diff)
Replace match with function chaining
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--src/main.rs5
1 files changed, 1 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs
index d12e2ce..4bfea0c 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -172,10 +172,7 @@ async fn on_get(req: Request<Body>) -> Result<Response<Body>, Box<dyn Error>> {
};
// If we have an extension, we need to serve with the appropriate Content-Type
- let mime = match &extension {
- Some(ext) => mime_guess::from_ext(&ext).first_raw(),
- None => None,
- };
+ let mime = extension.as_ref().and_then(|ext| mime_guess::from_ext(ext).first_raw());
// /ID.<extension> serves a page with javascript which does syntax highlighting,
// if the extension/mime is a type associated with a plain-text file type