Use expect instead of unwrap

This commit is contained in:
Dreaded_X 2023-12-01 12:02:16 +01:00
parent 75e5c02986
commit 30cd70bce9
Signed by: Dreaded_X
GPG Key ID: 5A0CBFE3C3377FAA

View File

@ -60,8 +60,10 @@ impl aoc::Solver for Day {
.lines()
.map(|line| {
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.next().unwrap();
let first = nums
.next()
.expect("Every line should have at least one number");
// If there is only one number use the first number as the last number
let last = nums.last().unwrap_or(first);