improve match statement to use pos table

This commit is contained in:
mos 2024-11-13 15:55:18 +01:00
parent a05bdc4c03
commit c71e0e16cf
1 changed files with 4 additions and 4 deletions

View File

@ -250,10 +250,10 @@ impl State {
fn move_dir(&mut self, dir: Direction) -> Result<(bool, bool)> { fn move_dir(&mut self, dir: Direction) -> Result<(bool, bool)> {
match dir { match dir {
Direction::U => self.move_pos(Pos(0, -1)), Direction::U => self.move_pos(Self::DIR_POS[0]),
Direction::D => self.move_pos(Pos(0, 1)), Direction::D => self.move_pos(Self::DIR_POS[1]),
Direction::L => self.move_pos(Pos(-1, 0)), Direction::L => self.move_pos(Self::DIR_POS[2]),
Direction::R => self.move_pos(Pos(1, 0)), Direction::R => self.move_pos(Self::DIR_POS[3]),
} }
} }