clippy fixes

clippy fixes #2

clippy fixed #3

removed unnecessary stuff
This commit is contained in:
2023-05-20 22:44:52 +02:00
parent ef2340eaae
commit b480601ee8
16 changed files with 127 additions and 149 deletions

View File

@@ -24,23 +24,21 @@ fn read_input() -> (Vec<Vec<char>>, Vec<Cart>) {
for (x, c) in line.chars().enumerate() {
if tiles.contains(&c) {
map[x][y] = c;
} else {
if c != ' ' {
map[x][y] = match c {
'>' => '-',
'<' => '-',
'^' => '-',
'v' => '-',
_ => panic!("{} is invalid input char at this point", c),
};
carts.push(Cart {
x,
y,
direction: c,
intersections_visited: 0,
active: true,
});
}
} else if c != ' ' {
map[x][y] = match c {
'>' => '-',
'<' => '-',
'^' => '-',
'v' => '-',
_ => panic!("{} is invalid input char at this point", c),
};
carts.push(Cart {
x,
y,
direction: c,
intersections_visited: 0,
active: true,
});
}
}
}
@@ -57,7 +55,7 @@ struct Cart {
active: bool,
}
fn perform_round(map: &Vec<Vec<char>>, carts: &mut Vec<Cart>) {
fn perform_round(map: &[Vec<char>], carts: &mut Vec<Cart>) {
carts.sort_unstable_by(|a, b| {
if a.y == b.y {
a.x.cmp(&b.x)