Simplified parent access
This commit is contained in:
parent
7a1141f5ee
commit
e1ebbedc27
@ -18,7 +18,7 @@ pub fn run() {
|
||||
for line in read("07").lines().skip(1) {
|
||||
if line.starts_with("$ cd") {
|
||||
current_directory = match line.split_once("cd ").unwrap().1 {
|
||||
dirname if ".." == dirname => current_directory.ancestors(arena).nth(1).unwrap(),
|
||||
dirname if ".." == dirname => arena.get(current_directory).unwrap().parent().unwrap(),
|
||||
dirname => current_directory
|
||||
.children(arena)
|
||||
.find(|c|arena.get(*c).unwrap().get().name == dirname)
|
||||
|
Loading…
Reference in New Issue
Block a user