Skip to content

Commit aff31c8

Browse files
committed
use map
1 parent 7945fa8 commit aff31c8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

examples/static-file-server/src/tests.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ async fn get_page(app: Router, path: &str) -> (StatusCode, Option<ContentType>,
1515
.unwrap();
1616

1717
let status = response.status();
18-
let content_type = match response.headers().get("content-type") {
19-
Some(header) => Some(header.to_str().unwrap().parse::<ContentType>().unwrap()),
20-
None => None,
21-
};
18+
let content_type = response
19+
.headers()
20+
.get("content-type")
21+
.map(|header| header.to_str().unwrap().parse::<ContentType>().unwrap());
2222

2323
let body = response.into_body();
2424
let bytes = body.collect().await.unwrap().to_bytes();

0 commit comments

Comments
 (0)