From 6dccc14046f8f442f563e2be28b93588aacd102f Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Sat, 4 Dec 2021 15:18:38 +0100 Subject: [PATCH] 2021: day04: better Iterator return type --- aoc2021/src/day04.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/aoc2021/src/day04.rs b/aoc2021/src/day04.rs index 1f5a4a6..2b0394e 100644 --- a/aoc2021/src/day04.rs +++ b/aoc2021/src/day04.rs @@ -46,7 +46,7 @@ fn part1(input: &str) -> Result { match (wdraw, wgrid) { (Some(draw), Some(grid)) => { - Ok(draw as u64 * grid.unmarked_numbers().map(|n| *n as u64).sum::()) + Ok(draw as u64 * grid.unmarked_numbers().map(|n| n as u64).sum::()) } _ => Err(anyhow!("couldn't find a winning grid!")), } @@ -89,7 +89,7 @@ fn part2(input: &str) -> Result { for draw in draws { if last_grid.mark(draw) { - return Ok(draw as u64 * last_grid.unmarked_numbers().map(|n| *n as u64).sum::()); + return Ok(draw as u64 * last_grid.unmarked_numbers().map(|n| n as u64).sum::()); } } @@ -120,10 +120,10 @@ impl Grid { } } - fn unmarked_numbers(&self) -> impl Iterator { + fn unmarked_numbers(&self) -> impl Iterator + '_ { self.number_to_pos .iter() - .filter_map(|(num, &(x, y))| (!self.access_grid(x, y)).then(|| num)) + .filter_map(|(num, &(x, y))| (!self.access_grid(x, y)).then(|| *num)) } fn access_grid(&self, x: usize, y: usize) -> bool {