@@ -168,11 +168,7 @@ impl<T: Idx> BitSet<T> {
168
168
/// Iterates over the indices of set bits in a sorted order.
169
169
#[ inline]
170
170
pub fn iter ( & self ) -> BitIter < ' _ , T > {
171
- BitIter {
172
- cur : None ,
173
- iter : self . words . iter ( ) . enumerate ( ) ,
174
- marker : PhantomData ,
175
- }
171
+ BitIter :: new ( & self . words )
176
172
}
177
173
178
174
/// Duplicates the set as a hybrid set.
@@ -296,6 +292,17 @@ pub struct BitIter<'a, T: Idx> {
296
292
marker : PhantomData < T >
297
293
}
298
294
295
+ impl < ' a , T : Idx > BitIter < ' a , T > {
296
+ #[ inline]
297
+ fn new ( words : & ' a [ Word ] ) -> BitIter < ' a , T > {
298
+ BitIter {
299
+ cur : None ,
300
+ iter : words. iter ( ) . enumerate ( ) ,
301
+ marker : PhantomData ,
302
+ }
303
+ }
304
+ }
305
+
299
306
impl < ' a , T : Idx > Iterator for BitIter < ' a , T > {
300
307
type Item = T ;
301
308
fn next ( & mut self ) -> Option < T > {
@@ -851,11 +858,7 @@ impl<R: Idx, C: Idx> BitMatrix<R, C> {
851
858
pub fn iter ( & self , row : R ) -> BitIter < ' _ , C > {
852
859
assert ! ( row. index( ) < self . num_rows) ;
853
860
let ( start, end) = self . range ( row) ;
854
- BitIter {
855
- cur : None ,
856
- iter : self . words [ start..end] . iter ( ) . enumerate ( ) ,
857
- marker : PhantomData ,
858
- }
861
+ BitIter :: new ( & self . words [ start..end] )
859
862
}
860
863
861
864
/// Returns the number of elements in `row`.
0 commit comments