Simplified parent access

This commit is contained in:
max.nuding 2022-12-07 09:28:35 +01:00
parent 7a1141f5ee
commit e1ebbedc27
Failed to extract signature

View File

@ -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)