use crate::Binvec;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct BinvecIter<'a, const L: usize, const N: usize> {
binvec: &'a Binvec<L, N>,
index: usize,
}
impl<'a, const L: usize, const N: usize> BinvecIter<'a, L, N> {
pub const fn new(binvec: &'a Binvec<L, N>) -> Self {
Self { binvec, index: 0 }
}
}
impl<'a, const L: usize, const N: usize> Iterator for BinvecIter<'a, L, N> {
type Item = bool;
fn next(&mut self) -> Option<Self::Item> {
if self.index < L {
let bit: bool = unsafe { self.binvec.get_unchecked(self.index) };
self.index += 1;
Some(bit)
} else {
None
}
}
}