Replace unwrap() by match
This commit is contained in:
parent
76d88e46ad
commit
a330cdd82f
1 changed files with 25 additions and 13 deletions
|
@ -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() {
|
||||
let year = match year {
|
||||
None => {
|
||||
debug!("No year");
|
||||
return None;
|
||||
}
|
||||
if month.is_none() {
|
||||
},
|
||||
Some(x) => x,
|
||||
};
|
||||
|
||||
let month = match month {
|
||||
None => {
|
||||
debug!("No month");
|
||||
return None;
|
||||
}
|
||||
if day.is_none() {
|
||||
},
|
||||
Some(x) => x,
|
||||
};
|
||||
|
||||
let day = match day {
|
||||
None => {
|
||||
debug!("No day");
|
||||
return None;
|
||||
}
|
||||
},
|
||||
Some(x) => x,
|
||||
};
|
||||
|
||||
Some(Date::new(year.unwrap(), month.unwrap(), day.unwrap()))
|
||||
|
||||
Some(Date::new(year, month, day))
|
||||
})
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue