projects
/
advent_of_code_2019.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
d252d35
)
loop -> while let
author
Grégory Burri
<gregory.burri@matisa.ch>
Mon, 9 Dec 2019 13:57:57 +0000
(14:57 +0100)
committer
Grégory Burri
<gregory.burri@matisa.ch>
Mon, 9 Dec 2019 13:57:57 +0000
(14:57 +0100)
src/day06.rs
patch
|
blob
|
history
diff --git
a/src/day06.rs
b/src/day06.rs
index
1923336
..
fddb899
100644
(file)
--- 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