Improve 'board::BitboardIterator'
* Accurate 'size_hint'. * Exact size. * Fused iterator (keeps returning 'None' after returning 'None' once).
This commit is contained in:
parent
f3a83065da
commit
0315e2fb51
|
@ -14,4 +14,14 @@ impl Iterator for BitboardIterator {
|
||||||
Some(crate::board::Square::from_index(lsb))
|
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 {}
|
||||||
|
|
Loading…
Reference in a new issue