From c71e0e16cfbd197df3b5f90c10bf5ad294d354e2 Mon Sep 17 00:00:00 2001 From: mos Date: Wed, 13 Nov 2024 15:55:18 +0100 Subject: [PATCH] improve match statement to use pos table --- src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 32f5807..46c4475 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -250,10 +250,10 @@ impl State { fn move_dir(&mut self, dir: Direction) -> Result<(bool, bool)> { match dir { - Direction::U => self.move_pos(Pos(0, -1)), - Direction::D => self.move_pos(Pos(0, 1)), - Direction::L => self.move_pos(Pos(-1, 0)), - Direction::R => self.move_pos(Pos(1, 0)), + Direction::U => self.move_pos(Self::DIR_POS[0]), + Direction::D => self.move_pos(Self::DIR_POS[1]), + Direction::L => self.move_pos(Self::DIR_POS[2]), + Direction::R => self.move_pos(Self::DIR_POS[3]), } }