(&mut self)
| 302 | type Item = usize; |
| 303 | |
| 304 | fn next(&mut self) -> Option<Self::Item> { |
| 305 | loop { |
| 306 | let tz = self.curr.trailing_zeros(); |
| 307 | if tz < B::BITS { |
| 308 | // Some bit was set; so yield the index of that |
| 309 | // and zero the bit out so we don't yield it again. |
| 310 | self.curr &= self.curr.wrapping_sub(B::ONE); |
| 311 | let idx = self.block_idx as u32 * B::BITS + tz; |
| 312 | return Some(idx as usize); |
| 313 | } else { |
| 314 | // No bit is set; advance to the next block, or quit if none left. |
| 315 | self.curr = *self.inner.next()?; |
| 316 | self.block_idx += 1; |
| 317 | } |
| 318 | } |
| 319 | } |
| 320 | } |
| 321 | |
| 322 | #[cfg(test)] |
no test coverage detected