From: Greg Burri Date: Wed, 18 Nov 2020 15:26:02 +0000 (+0100) Subject: use 'enumerate' instead of a custom variable. X-Git-Url: https://git.euphorik.ch/?a=commitdiff_plain;h=398635c71e721891cac1e02d2251b36739a12638;p=advent_of_code_2019.git use 'enumerate' instead of a custom variable. --- 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 } }