From: Grégory Burri Date: Mon, 9 Dec 2019 13:57:57 +0000 (+0100) Subject: loop -> while let X-Git-Url: http://git.euphorik.ch/index.cgi?a=commitdiff_plain;h=34baa0f28094067e50ea639b9d632a8451f90f07;p=advent_of_code_2019.git loop -> while let --- diff --git a/src/day06.rs b/src/day06.rs index 1923336..fddb899 100644 --- a/src/day06.rs +++ b/src/day06.rs @@ -17,11 +17,9 @@ fn parents<'a>(orbits: &'a Orbits, planet: &str) -> Vec<&'a str> { let mut parents = Vec::<&str>::new(); let mut current_planet = planet; - loop { - match orbits.get(current_planet) { - Some (parent) => { parents.insert(0, parent); current_planet = parent; }, - None => break - } + while let Some (parent) = orbits.get(current_planet) { + parents.insert(0, parent); + current_planet = parent; } parents