improve match statement to use pos table
This commit is contained in:
parent
a05bdc4c03
commit
c71e0e16cf
|
@ -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]),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue