From 9ee9281c489fe372e7586be77a6df4f4ab7c7ba8 Mon Sep 17 00:00:00 2001 From: Greg Burri Date: Wed, 18 Nov 2020 16:26:02 +0100 Subject: [PATCH] use 'enumerate' instead of a custom variable. --- src/day18.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/day18.rs b/src/day18.rs index c9eda6b..cd0c0ac 100644 --- a/src/day18.rs +++ b/src/day18.rs @@ -15,14 +15,12 @@ const FLOOR_SYMBOL: char = '.'; impl Vault { pub fn parse(input: &str) -> Self { let mut tunnels = Vec::>::new(); - let mut row = 0; let mut entrance = (0, 0); - for line in input.lines() { + for (row, line) in input.lines().enumerate() { tunnels.push(line.trim().chars().collect::>()); if let Some((col, _)) = tunnels.last().unwrap().iter().find_position(|c| c == &&START_SYMBOL) { - entrance = (row, col as i32); + entrance = (row as i32, col as i32); } - row += 1; } Vault { tunnels, entrance } } -- 2.45.2