const_fn bitvec + bitvec build fixes

This commit is contained in:
2025-02-18 23:44:56 -05:00
parent c14e5703ef
commit 2ef316ab52
4 changed files with 32 additions and 6 deletions

View File

@@ -1,4 +1,5 @@
use crate::board::{BOARD_AREA, BOARD_SIZE};
use const_fn::const_fn;
use static_assertions::const_assert;
// quick explanation for the dual-nature of [`BitBoard`]
@@ -11,7 +12,10 @@ use static_assertions::const_assert;
use bitvec::prelude::*;
#[cfg(feature = "bitvec")]
pub type BitBoardInner = BitArr!(for BOARD_AREA, in u64, Lsb0);
type BBBaseType = u64;
#[cfg(feature = "bitvec")]
pub type BitBoardInner = BitArr!(for BOARD_AREA, in BBBaseType, Lsb0);
#[cfg(not(feature = "bitvec"))]
pub type BitBoardInner = u64;
@@ -78,7 +82,8 @@ impl BitBoard {
self.0.set(Self::get_index(row, col), value);
}
// works on both `bitvec` and native
// works on both `bitvec` and native (const on native)
#[const_fn(cfg(not(feature = "bitvec")))]
pub fn count(&self) -> usize {
self.0.count_ones() as usize
}