share some code between bitvec and native
This commit is contained in:
parent
45224bf6c2
commit
c14e5703ef
@ -64,11 +64,6 @@ impl BitBoard {
|
|||||||
self.0 |= 1 << index
|
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 {
|
const fn get_index(row: usize, col: usize) -> usize {
|
||||||
row * BOARD_SIZE + col
|
row * BOARD_SIZE + col
|
||||||
}
|
}
|
||||||
@ -83,9 +78,9 @@ impl BitBoard {
|
|||||||
self.0.set(Self::get_index(row, col), value);
|
self.0.set(Self::get_index(row, col), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "bitvec")]
|
// works on both `bitvec` and native
|
||||||
pub fn count(&self) -> usize {
|
pub fn count(&self) -> usize {
|
||||||
self.0.count_ones()
|
self.0.count_ones() as usize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user