From 7accdf8f480a34353c4d190ef893e51242275553 Mon Sep 17 00:00:00 2001 From: khai96_ Date: Fri, 26 Apr 2019 17:15:46 +0700 Subject: Use 'if let' --- src/args.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/args.rs') diff --git a/src/args.rs b/src/args.rs index 97b391f..4077f35 100644 --- a/src/args.rs +++ b/src/args.rs @@ -97,9 +97,10 @@ fn parse_auth(src: &str) -> Result { }; let password = if let Some(hash_hex) = split.next() { - let hash_bin = match hex::decode(hash_hex) { - Ok(hash_bin) => hash_bin, - _ => return Err(ContextualError::new(ContextualErrorKind::InvalidPasswordHash)), + let hash_bin = if let Ok(hash_bin) = hex::decode(hash_hex) { + hash_bin + } else { + return Err(ContextualError::new(ContextualErrorKind::InvalidPasswordHash)) }; match second_part { -- cgit v1.2.3