From 7f72b7805357eb7b7f514c8bdf86128005fb64d3 Mon Sep 17 00:00:00 2001 From: Simon Sawert Date: Wed, 6 May 2020 08:11:26 +0200 Subject: [PATCH] Fix clippy warnings --- src/lib.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 9539ee3..75180d2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -55,12 +55,7 @@ impl Personnummer { ).unwrap(); } - let cap = PNR_REGEX.captures(pnr); - if cap.is_none() { - return None; - } - - let caps = cap.unwrap(); + let caps = PNR_REGEX.captures(pnr)?; let century = match caps.name("century") { Some(m) => m.as_str().parse::().unwrap_or(19) * 100, @@ -119,14 +114,14 @@ impl Personnummer { day }; - let long = String::from(format!( + let long = format!( "{}{:02}{:02}-{:03}{}", self.date.year(), self.date.month(), day_or_coordination, self.serial, self.control - )); + ); let short = String::from(&long.clone()[2..]);