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