Skip to content

Commit

Permalink
match => Option::map (#42)
Browse files Browse the repository at this point in the history
Use `Option::<usize>::map` instead of a `match` expression in
the `parse_month` function.
  • Loading branch information
vikrrrr authored and mre committed Jul 3, 2018
1 parent b49908c commit 5e4c0a3
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions episode/7/humandate/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ impl From<std::num::ParseIntError> for Error {
}

fn parse_month(month: &str) -> Option<usize> {
match MONTH_NAMES.iter().position(|&elem| elem == month) {
Some(index) => Some(index + 1),
None => None,
}
MONTH_NAMES.iter().position(|&elem| elem == month).map(|day| day + 1)
}

fn parse_day(day_with_ordinal: &str) -> Result<u32, Error> {
Expand Down

0 comments on commit 5e4c0a3

Please sign in to comment.