From 63d2ccd64bfc253b65b046b17daf9b2d0cf842bd Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Thu, 21 May 2026 13:51:27 -0400 Subject: [PATCH] compiler/rust/bitset: Generalize BitSetIterator It now iterates over a slice instead of a BitSet Reviewed-by: Mel Henning Part-of: --- src/compiler/rust/bitset.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/compiler/rust/bitset.rs b/src/compiler/rust/bitset.rs index d9329156107..4e9d985122e 100644 --- a/src/compiler/rust/bitset.rs +++ b/src/compiler/rust/bitset.rs @@ -245,7 +245,7 @@ impl BitSet { impl BitSet { pub fn iter(&self) -> impl '_ + Iterator { - BitSetIter::new(self) + BitSetIter::new(&self.words) } } @@ -550,15 +550,17 @@ binop!( ); struct BitSetIter<'a, K> { - set: &'a BitSet, + words: &'a [u32], idx: BitIndex, + phantom: PhantomData, } impl<'a, K> BitSetIter<'a, K> { - fn new(set: &'a BitSet) -> Self { + fn new(words: &'a [u32]) -> Self { Self { - set, + words, idx: BitIndex::ZERO, + phantom: PhantomData, } } } @@ -567,11 +569,11 @@ impl<'a, K: FromBitIndex> Iterator for BitSetIter<'a, K> { type Item = K; fn next(&mut self) -> Option { - if let Some(idx) = find_next_set(&self.set.words, self.idx) { + if let Some(idx) = find_next_set(self.words, self.idx) { self.idx = idx + 1; Some(K::from_bit_index(idx.into())) } else { - self.idx = BitIndex::from_word(self.set.words.len()); + self.idx = BitIndex::from_word(self.words.len()); None } }