[board] Rename BitBoard::pieces() → occupied_squares()

This commit is contained in:
Eryn Wells 2023-12-26 09:15:53 -07:00
parent e0f1e1f6ff
commit 48f393680c

View file

@ -82,7 +82,7 @@ impl BitBoard {
}
impl BitBoard {
fn pieces(&self) -> impl Iterator<Item = Square> {
pub(crate) fn occupied_squares(&self) -> impl Iterator<Item = Square> {
BitScanner::new(self.0)
.map(|x| u8::try_from(x))
.take_while(|x| x.is_ok())
@ -231,11 +231,11 @@ mod tests {
fn pieces() {
let bb = BitBoard(0x1001_1010); // e4
let mut pieces = bb.pieces();
assert_eq!(pieces.next(), Some(Square::from_index_unsafe(28)));
assert_eq!(pieces.next(), Some(Square::from_index_unsafe(16)));
assert_eq!(pieces.next(), Some(Square::from_index_unsafe(12)));
assert_eq!(pieces.next(), Some(Square::from_index_unsafe(4)));
assert_eq!(pieces.next(), None);
let mut occupied_squares = bb.occupied_squares();
assert_eq!(occupied_squares.next(), Some(Square::from_index_unsafe(28)));
assert_eq!(occupied_squares.next(), Some(Square::from_index_unsafe(16)));
assert_eq!(occupied_squares.next(), Some(Square::from_index_unsafe(12)));
assert_eq!(occupied_squares.next(), Some(Square::from_index_unsafe(4)));
assert_eq!(occupied_squares.next(), None);
}
}