board backing referencing improvements

This commit is contained in:
2025-03-10 21:48:31 -04:00
parent 54f7b8e472
commit 69dc686d0a
3 changed files with 65 additions and 38 deletions

View File

@@ -20,9 +20,13 @@ impl CoordPair {
Self(row * Board::BOARD_SIZE + col)
}
fn from_index(&self) -> (CoordAxis, CoordAxis) {
fn into_indexes(&self) -> (CoordAxis, CoordAxis) {
self.0.div_mod_floor(&Board::BOARD_SIZE)
}
pub const fn area(pos: CoordAxis) -> Self {
Self(pos.pow(2) as CoordPairInner)
}
}
impl std::fmt::Display for CoordPair {
@@ -40,7 +44,7 @@ impl std::fmt::Debug for CoordPair {
impl From<CoordPair> for (CoordAxis, CoordAxis) {
fn from(val: CoordPair) -> Self {
val.from_index()
val.into_indexes()
}
}