File tree Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -118,7 +118,7 @@ impl IntoIterator for PrimitiveTypesBitMap {
118
118
type IntoIter = PrimitiveTypesBitMapIterator ;
119
119
fn into_iter ( self ) -> Self :: IntoIter {
120
120
PrimitiveTypesBitMapIterator {
121
- range : 0 .. 7 ,
121
+ idx : 0 ,
122
122
bit_map : self ,
123
123
}
124
124
}
@@ -137,23 +137,21 @@ impl From<Vec<PrimitiveType>> for PrimitiveTypesBitMap {
137
137
/// Iterator over all `PrimitiveType` present in a `PrimitiveTypesBitMap`
138
138
#[ derive( Debug ) ]
139
139
pub struct PrimitiveTypesBitMapIterator {
140
- range : std :: ops :: Range < u8 > ,
140
+ idx : u8 ,
141
141
bit_map : PrimitiveTypesBitMap ,
142
142
}
143
143
impl Iterator for PrimitiveTypesBitMapIterator {
144
144
type Item = PrimitiveType ;
145
145
#[ allow( clippy:: integer_arithmetic) ]
146
146
fn next ( & mut self ) -> Option < Self :: Item > {
147
- loop {
148
- if let Some ( value) = self . range . next ( ) {
149
- let bit_value = 1 << value;
150
- if self . bit_map . inner & bit_value != 0 {
151
- return Some ( bit_map_representation_primitive_type ( bit_value) ) ;
152
- }
153
- } else {
154
- return None ;
147
+ while self . idx <= 7 {
148
+ let bit_value = 1 << self . idx ;
149
+ self . idx += 1 ;
150
+ if self . bit_map . inner & bit_value != 0 {
151
+ return Some ( bit_map_representation_primitive_type ( bit_value) ) ;
155
152
}
156
153
}
154
+ None
157
155
}
158
156
}
159
157
You can’t perform that action at this time.
0 commit comments