Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::{
cmp::{min, PartialEq},
fmt::{self, Debug},
hash::{Hash, Hasher},
iter::{DoubleEndedIterator, FromIterator},
iter::{DoubleEndedIterator, FromIterator, FusedIterator},
mem::{replace, size_of},
ops::{
Bound::{Excluded, Included, Unbounded},
Expand Down Expand Up @@ -1182,6 +1182,8 @@ impl<T: Debug + PrimInt> DoubleEndedIterator for IterSetBits<'_, T> {
}
}

impl<T: Debug + PrimInt> FusedIterator for IterSetBits<'_, T> {}

#[derive(Clone)]
pub struct IterUnsetBits<'a, T: 'a> {
vob: &'a Vob<T>,
Expand Down Expand Up @@ -1260,6 +1262,8 @@ impl<T: Debug + PrimInt> DoubleEndedIterator for IterUnsetBits<'_, T> {
}
}

impl<T: Debug + PrimInt> FusedIterator for IterUnsetBits<'_, T> {}

impl<T: Debug + PrimInt> PartialEq for Vob<T> {
fn eq(&self, other: &Self) -> bool {
if self.len != other.len {
Expand Down Expand Up @@ -1914,6 +1918,21 @@ mod tests {
t(&v1, 128.., vec![129, 130, 256]);
}

#[test]
fn test_fused() {
let v1 = vob![true];
let mut i1 = v1.iter_set_bits(..);
assert!(i1.next().is_some());
assert!(i1.next().is_none());
assert!(i1.next().is_none());

let v2 = vob![false];
let mut i2 = v2.iter_unset_bits(..);
assert!(i2.next().is_some());
assert!(i2.next().is_none());
assert!(i2.next().is_none());
}

#[test]
fn test_eq() {
let v1 = Vob::from_iter(vec![true, false]);
Expand Down