Add 'BitboardIterator::new'

This commit is contained in:
Bruno BELANYI 2024-03-31 12:08:34 +01:00
parent 06087358de
commit 3b1735da79
2 changed files with 11 additions and 3 deletions

View file

@ -1,6 +1,14 @@
/// An [Iterator](std::iter::Iterator) of [Square](crate::board::Square) contained in a
/// [Bitboard](crate::board::Bitboard).
pub struct BitboardIterator(pub(crate) u64);
/// [Bitboard].
use crate::board::Bitboard;
pub struct BitboardIterator(u64);
impl BitboardIterator {
pub fn new(board: Bitboard) -> Self {
Self(board.0)
}
}
impl Iterator for BitboardIterator {
type Item = crate::board::Square;

View file

@ -91,7 +91,7 @@ impl IntoIterator for Bitboard {
type Item = Square;
fn into_iter(self) -> Self::IntoIter {
BitboardIterator(self.0)
BitboardIterator::new(self)
}
}