From 7a18e247f439d4ff2921df330e528650bba4a55f Mon Sep 17 00:00:00 2001 From: Gaelan Steele Date: Sun, 28 Mar 2021 23:08:27 -0700 Subject: [PATCH] api_client: use Option::map in get_header It's more idiomatic Rust, and satisfies nightly clippy. Signed-off-by: Gaelan Steele --- api_client/src/lib.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/api_client/src/lib.rs b/api_client/src/lib.rs index 1d1f639eb..db553fe2b 100644 --- a/api_client/src/lib.rs +++ b/api_client/src/lib.rs @@ -76,11 +76,8 @@ impl StatusCode { fn get_header<'a>(res: &'a str, header: &'a str) -> Option<&'a str> { let header_str = format!("{}: ", header); - if let Some(o) = res.find(&header_str) { - Some(&res[o + header_str.len()..o + res[o..].find('\r').unwrap()]) - } else { - None - } + res.find(&header_str) + .map(|o| &res[o + header_str.len()..o + res[o..].find('\r').unwrap()]) } fn get_status_code(res: &str) -> Result {