Use expect instead of unwrap
This commit is contained in:
parent
75e5c02986
commit
30cd70bce9
|
@ -60,8 +60,10 @@ impl aoc::Solver for Day {
|
||||||
.lines()
|
.lines()
|
||||||
.map(|line| {
|
.map(|line| {
|
||||||
let mut nums = line.chars().filter_map(|c| c.to_digit(10));
|
let mut nums = line.chars().filter_map(|c| c.to_digit(10));
|
||||||
// There is always at least one number in every line
|
let first = nums
|
||||||
let first = nums.next().unwrap();
|
.next()
|
||||||
|
.expect("Every line should have at least one number");
|
||||||
|
|
||||||
// If there is only one number use the first number as the last number
|
// If there is only one number use the first number as the last number
|
||||||
let last = nums.last().unwrap_or(first);
|
let last = nums.last().unwrap_or(first);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user