From 41af614d74203d0d88abb62e6178d84c2a83c17f Mon Sep 17 00:00:00 2001 From: mos Date: Tue, 29 Oct 2024 19:33:19 +0100 Subject: [PATCH] use DIR_POS for box testing --- src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index b921576..efbaec1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -189,6 +189,8 @@ struct State { } impl State { + const DIR_POS: &'static [Pos] = &[Pos(0, -1), Pos(0, 1), Pos(-1, 0), Pos(1, 0)]; + fn new(lvl: Level) -> Self { State { lvl } } @@ -250,10 +252,9 @@ impl State { } fn test_box(&self, pos: Pos, bt: bool) -> bool { - let dir: &[Pos] = &[Pos(0, -1), Pos(0, 1), Pos(-1, 0), Pos(1, 0)]; let mut mbc = 0; - for i in dir { + for i in Self::DIR_POS { match self.lvl[pos + *i] { Cell::Goal(false) | Cell::None => { let dpos = pos - *i;