1
0

Small bug
All checks were successful
CI / Typos (push) Successful in 8s
CI / Build (push) Successful in 43s
CI / Clippy (push) Successful in 1m0s

This commit is contained in:
Mark 2025-03-05 21:33:17 -08:00
parent cf60d6734a
commit 8893395878
Signed by: Mark
GPG Key ID: C6D63995FE72FD80

View File

@ -97,12 +97,28 @@ impl TetrisBoard {
/// Get the value of the cell at the given position.
/// Returns [`None`] if (x, y) exceeds the board's bounds.
pub fn get_cell(&self, x: usize, y: usize) -> Option<&TetrisCell> {
if y >= TetrisBoard::BOARD_HEIGHT {
return None;
}
if x >= TetrisBoard::BOARD_WIDTH {
return None;
}
return self.board.get(y * TetrisBoard::BOARD_WIDTH + x);
}
/// Get a mutable reference to the cell at the given position.
/// Returns [`None`] if (x, y) exceeds the board's bounds.
pub fn get_cell_mut(&mut self, x: usize, y: usize) -> Option<&mut TetrisCell> {
if y >= TetrisBoard::BOARD_HEIGHT {
return None;
}
if x >= TetrisBoard::BOARD_WIDTH {
return None;
}
return self.board.get_mut(y * TetrisBoard::BOARD_WIDTH + x);
}
}