From 8050b16034717aef8f332bf81277566f5b4b3063 Mon Sep 17 00:00:00 2001 From: kageru Date: Wed, 7 Dec 2022 14:03:06 +0100 Subject: [PATCH] remove unneeded box --- 2022/src/bin/day07.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/2022/src/bin/day07.rs b/2022/src/bin/day07.rs index 4bc640d..38786e1 100644 --- a/2022/src/bin/day07.rs +++ b/2022/src/bin/day07.rs @@ -7,7 +7,7 @@ const DAY: usize = 7; enum Node<'a> { File(&'a str, usize), - Dir(&'a str, Vec>>, usize), + Dir(&'a str, Vec>, usize), } impl<'a> Node<'a> { @@ -16,7 +16,7 @@ impl<'a> Node<'a> { fn subdir_mut(&mut self, dir: &str) -> &mut Self { match self { Self::Dir(_, contents, _) => { - contents.iter_mut().find(|d| matches!(***d, Self::Dir(name, _, _) if name == dir)).expect("File not found") + contents.iter_mut().find(|d| matches!(**d, Self::Dir(name, _, _) if name == dir)).expect("File not found") } Self::File(name, _) => panic!("Can't index into a file ({name})"), } @@ -36,8 +36,8 @@ fn parse_input(raw: &str) -> Node<'_> { lines .filter_map(|l| l.split_once(' ')) .map(|line| match line { - ("dir", d) => Box::new(Node::Dir(d, Vec::new(), 0)), - (size, name) => Box::new(Node::File(name, size.parse().unwrap())) + ("dir", d) => Node::Dir(d, Vec::new(), 0), + (size, name) => Node::File(name, size.parse().unwrap()) }) .collect_into(contents); }