mirror of
https://github.com/szymon-jozef/checkers.git
synced 2026-10-28 11:10:44 +01:00
refactor: use index<usize> in index<Position> implementation
This commit is contained in:
@@ -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]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user