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; - } + let year = match year { + None => { + debug!("No year"); + return None; + }, + Some(x) => x, + }; - Some(Date::new(year.unwrap(), month.unwrap(), day.unwrap())) + 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)) }) } 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); + let hour = match capts.name("h").and_then(|o| FromStr::from_str(o).ok()) { + None => { + debug!("No hour"); + return None; + }, + Some(x) => x, + }; - if hour.is_none() { - debug!("No hour"); - return None; - } - - Some(Time::new(hour.unwrap(), minute, second)) + Some(Time::new(hour, minute, second)) }) }