refactor: use index<usize> in index<Position> implementation

This commit is contained in:
2026-08-12 00:48:47 +02:00
parent 0d1a9cafbb
commit 990c133bc6

View File

@@ -121,8 +121,7 @@ impl Index<Position> for Board {
type Output = Field; type Output = Field;
fn index(&self, index: Position) -> &Self::Output { fn index(&self, index: Position) -> &Self::Output {
let index = index.row * &self.size + index.column; &self[index.row][index.column]
&self.board[index]
} }
} }
@@ -136,8 +135,7 @@ impl IndexMut<usize> for Board {
impl IndexMut<Position> for Board { impl IndexMut<Position> for Board {
fn index_mut(&mut self, index: Position) -> &mut Self::Output { fn index_mut(&mut self, index: Position) -> &mut Self::Output {
let index = index.row * &self.size + index.column; &mut self[index.row][index.column]
&mut self.board[index]
} }
} }