share some code between bitvec and native

This commit is contained in:
Simon Gardling 2025-02-18 23:36:12 -05:00
parent 45224bf6c2
commit c14e5703ef
Signed by: titaniumtown
GPG Key ID: 9AB28AC10ECE533D

View File

@ -64,11 +64,6 @@ impl BitBoard {
self.0 |= 1 << index
}
#[cfg(not(feature = "bitvec"))]
pub const fn count(&self) -> usize {
self.0.count_ones() as usize
}
const fn get_index(row: usize, col: usize) -> usize {
row * BOARD_SIZE + col
}
@ -83,9 +78,9 @@ impl BitBoard {
self.0.set(Self::get_index(row, col), value);
}
#[cfg(feature = "bitvec")]
// works on both `bitvec` and native
pub fn count(&self) -> usize {
self.0.count_ones()
self.0.count_ones() as usize
}
}