diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2016-08-04 14:19:25 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2016-08-04 14:19:25 +0200 |
commit | 1762b2e7d52c5ce4e033f566ccd647cc82ecfa1e (patch) | |
tree | ab7d4eba73dd94abe3d6d68e1a0f372e77b2a4cd /libimagtimeui | |
parent | a330cdd82fe457a5069df2e0d7b53751c0115f07 (diff) |
Replace unwrap() by match
Diffstat (limited to 'libimagtimeui')
-rw-r--r-- | libimagtimeui/src/time.rs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/libimagtimeui/src/time.rs b/libimagtimeui/src/time.rs index 7c494bf8..dc5cbc1a 100644 --- a/libimagtimeui/src/time.rs +++ b/libimagtimeui/src/time.rs @@ -53,16 +53,17 @@ impl Parse for Time { R.captures(s) .and_then(|capts| { - let hour = capts.name("h").and_then(|o| FromStr::from_str(o).ok()); let minute = capts.name("m").and_then(|o| FromStr::from_str(o).ok()).unwrap_or(0); let second = capts.name("s").and_then(|o| FromStr::from_str(o).ok()).unwrap_or(0); - - if hour.is_none() { - debug!("No hour"); - return None; - } - - Some(Time::new(hour.unwrap(), minute, second)) + let hour = match capts.name("h").and_then(|o| FromStr::from_str(o).ok()) { + None => { + debug!("No hour"); + return None; + }, + Some(x) => x, + }; + + Some(Time::new(hour, minute, second)) }) } |