From fde8fb960be14c7f60efd442b1b753c1ea2b44f9 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Sat, 11 Jan 2020 15:42:01 +0300 Subject: [PATCH] oauth2: replace unwrap() and is_none() with "if let" --- src/oauth2.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/oauth2.rs b/src/oauth2.rs index f66f85a63..db00d8ec5 100644 --- a/src/oauth2.rs +++ b/src/oauth2.rs @@ -312,13 +312,12 @@ impl Oauth2 { } if let Ok(response) = parsed { // serde_json::Value.as_str() removes the quotes of json-strings - let addr = response.get("email"); - if addr.is_none() { + if let Some(addr) = response.get("email") { + Some(addr.to_string()) + } else { warn!(context, "E-mail missing in userinfo."); - return None; + None } - let addr = addr.unwrap().as_str(); - addr.map(|addr| addr.to_string()) } else { warn!(context, "Failed to parse userinfo."); None