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;