Improve 'board::BitboardIterator'
All checks were successful
continuous-integration/drone/push Build is passing

* 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 7c8dce8f49
commit b3222276ab

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 {}