Finds the position of the n-th set bit (1-based) starting from `start` index. If fewer than `n` set bits are found, returns the length of the buffer.
(&self, start: usize, n: usize)
| 443 | /// Finds the position of the n-th set bit (1-based) starting from `start` index. |
| 444 | /// If fewer than `n` set bits are found, returns the length of the buffer. |
| 445 | pub fn find_nth_set_bit_position(&self, start: usize, n: usize) -> usize { |
| 446 | if n == 0 { |
| 447 | return start; |
| 448 | } |
| 449 | |
| 450 | self.slice(start, self.bit_len - start) |
| 451 | .set_indices() |
| 452 | .nth(n - 1) |
| 453 | .map(|idx| start + idx + 1) |
| 454 | .unwrap_or(self.bit_len) |
| 455 | } |
| 456 | |
| 457 | /// Returns a [`BitChunks`] instance which can be used to iterate over |
| 458 | /// this buffer's bits in `u64` chunks |
nothing calls this directly
no test coverage detected