day(04): use new parsing function
Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
parent
153f02a831
commit
a13721bcb5
1 changed files with 3 additions and 12 deletions
|
@ -15,19 +15,10 @@ impl FromStr for Card {
|
|||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
let mut parts = s.split(':').nth(1).unwrap().split('|');
|
||||
let (winning, draw) = (parts.next().unwrap(), parts.next().unwrap());
|
||||
|
||||
let winning = parts
|
||||
.next()
|
||||
.unwrap()
|
||||
.split_ascii_whitespace()
|
||||
.map(|n| n.parse().unwrap())
|
||||
.collect();
|
||||
let draw = parts
|
||||
.next()
|
||||
.unwrap()
|
||||
.split_ascii_whitespace()
|
||||
.map(|n| n.parse().unwrap())
|
||||
.collect();
|
||||
let winning: HashSet<i32> = parse_ws_separated(winning);
|
||||
let draw: Vec<i32> = parse_ws_separated(draw);
|
||||
|
||||
Ok(Card { winning, draw })
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue