From 34baa0f28094067e50ea639b9d632a8451f90f07 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gr=C3=A9gory=20Burri?= Date: Mon, 9 Dec 2019 14:57:57 +0100 Subject: [PATCH] loop -> while let --- src/day06.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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 -- 2.45.2