Replace unwrap() by match
This commit is contained in:
parent
a330cdd82f
commit
1762b2e7d5
1 changed files with 8 additions and 7 deletions
|
@ -53,16 +53,17 @@ impl Parse for Time {
|
||||||
|
|
||||||
R.captures(s)
|
R.captures(s)
|
||||||
.and_then(|capts| {
|
.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 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 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() {
|
Some(Time::new(hour, minute, second))
|
||||||
debug!("No hour");
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
|
|
||||||
Some(Time::new(hour.unwrap(), minute, second))
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue