Rust Day 7 - Better cd /

This commit is contained in:
Tobias Berger 2022-12-07 10:50:17 +01:00
parent a296f62b58
commit ec9f1e92bc
Signed by: toby
GPG key ID: 2D05EFAB764D6A88
2 changed files with 4 additions and 6 deletions

View file

@ -9,9 +9,8 @@ pub(crate) fn part_1(input: &Vec<ConsoleLine>) -> usize {
for line in input {
match line {
ConsoleLine::MoveRoot => {
while current_directory.len() > 1 {
current_directory.pop();
}
current_directory.clear();
current_directory.push("");
}
ConsoleLine::MoveUp => {
current_directory.pop();

View file

@ -11,9 +11,8 @@ pub(crate) fn part_2(input: &Vec<ConsoleLine>) -> usize {
for line in input {
match line {
ConsoleLine::MoveRoot => {
while current_directory.len() > 1 {
current_directory.pop();
}
current_directory.clear();
current_directory.push("");
}
ConsoleLine::MoveUp => {
current_directory.pop();