Skip to content

Commit

Permalink
minor day 2 cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kcaffrey committed Dec 8, 2023
1 parent 3f29d8a commit 734c363
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/bin/02.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,14 @@ impl FromStr for Game {
if game_id.len() < 6 {
return Err(ParseGameErr);
}
let id = game_id[5..].parse::<u32>().map_err(|_| ParseGameErr)?;
let reveals = reveal_str
.trim()
.split(';')
.map(|reveal| reveal.parse::<Colors>())
.collect::<Result<SmallVec<[_; 10]>, _>>()?;
Ok(Self { id, reveals })
Ok(Self {
id: game_id[5..].parse::<u32>().map_err(|_| ParseGameErr)?,
reveals: reveal_str
.trim()
.split(';')
.map(|reveal| reveal.parse::<Colors>())
.collect::<Result<_, _>>()?,
})
}
}

Expand Down

0 comments on commit 734c363

Please sign in to comment.