borrow pos

This commit is contained in:
mos 2024-10-10 16:41:31 +02:00
parent fdbc4ad83d
commit cf012a78e3
1 changed files with 4 additions and 4 deletions

View File

@ -193,8 +193,8 @@ impl State {
State { lvl }
}
fn toggle_box(&mut self, pos: Pos) {
self.lvl[pos] = if self.lvl[pos] == Cell::Goal(true) {
fn toggle_box(&mut self, pos: &Pos) {
self.lvl[*pos] = if self.lvl[*pos] == Cell::Goal(true) {
Cell::Goal(false)
} else {
Cell::None
@ -219,13 +219,13 @@ impl State {
match self.lvl[bpos] {
Cell::None => {
self.toggle_box(dpos);
self.toggle_box(&dpos);
self.lvl[bpos] = Cell::Box;
self.lvl.player = dpos;
return Ok((false, false));
}
Cell::Goal(false) => {
self.toggle_box(dpos);
self.toggle_box(&dpos);
self.lvl[bpos] = Cell::Goal(true);
self.lvl.player = dpos;
return Ok((true, false));