Improve 'board::BitboardIterator'

* Accurate 'size_hint'.
* Exact size.
* Fused iterator (keeps returning 'None' after returning 'None' once).
This commit is contained in:
Bruno BELANYI 2022-07-18 18:21:14 +02:00
parent f3a83065da
commit 0315e2fb51

View file

@ -14,4 +14,14 @@ impl Iterator for BitboardIterator {
Some(crate::board::Square::from_index(lsb))
}
}
fn size_hint(&self) -> (usize, Option<usize>) {
let size = self.0.count_ones() as usize;
(size, Some(size))
}
}
impl ExactSizeIterator for BitboardIterator {}
impl std::iter::FusedIterator for BitboardIterator {}