diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2016-08-04 14:18:13 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2016-08-04 14:18:13 +0200 |
commit | a330cdd82fe457a5069df2e0d7b53751c0115f07 (patch) | |
tree | a12e09fa225eb78d984646c11275dfe77efb2c60 /libimagtimeui | |
parent | 76d88e46adf378e6823e7540463d4d70fd281f7f (diff) |
Replace unwrap() by match
Diffstat (limited to 'libimagtimeui')
-rw-r--r-- | libimagtimeui/src/date.rs | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/libimagtimeui/src/date.rs b/libimagtimeui/src/date.rs index fb2e57cc..987ad764 100644 --- a/libimagtimeui/src/date.rs +++ b/libimagtimeui/src/date.rs @@ -58,20 +58,32 @@ impl Parse for Date { let month = capts.name("M").and_then(|o| FromStr::from_str(o).ok()); let day = capts.name("D").and_then(|o| FromStr::from_str(o).ok()); - if year.is_none() { - debug!("No year"); - return None; - } - if month.is_none() { - debug!("No month"); - return None; - } - if day.is_none() { - debug!("No day"); - return None; - } - - Some(Date::new(year.unwrap(), month.unwrap(), day.unwrap())) + let year = match year { + None => { + debug!("No year"); + return None; + }, + Some(x) => x, + }; + + let month = match month { + None => { + debug!("No month"); + return None; + }, + Some(x) => x, + }; + + let day = match day { + None => { + debug!("No day"); + return None; + }, + Some(x) => x, + }; + + + Some(Date::new(year, month, day)) }) } |