move get_index to misc.rs

This commit is contained in:
2025-02-22 19:41:20 -05:00
parent 7c4f05af3e
commit c8ac4ce84b
3 changed files with 12 additions and 13 deletions

View File

@@ -1,4 +1,4 @@
use super::board::Board;
use super::{board::Board, misc::get_index};
use const_fn::const_fn;
use static_assertions::const_assert;
@@ -41,7 +41,7 @@ impl BitBoard {
#[const_fn(cfg(not(feature = "bitvec")))]
pub const fn get(&self, row: usize, col: usize) -> bool {
self.get_by_index(Self::get_index(row, col))
self.get_by_index(get_index(row, col))
}
#[cfg(not(feature = "bitvec"))]
@@ -51,7 +51,7 @@ impl BitBoard {
#[const_fn(cfg(not(feature = "bitvec")))]
pub const fn set(&mut self, row: usize, col: usize, value: bool) {
self.set_by_index(Self::get_index(row, col), value);
self.set_by_index(get_index(row, col), value);
}
#[cfg(not(feature = "bitvec"))]
@@ -61,10 +61,6 @@ impl BitBoard {
self.0 |= (value as BitBoardInner) << index; // set bit (if needed)
}
const fn get_index(row: usize, col: usize) -> usize {
row * Board::BOARD_SIZE + col
}
#[cfg(feature = "bitvec")]
pub fn get_by_index(&self, index: usize) -> bool {
self.0[index]