/// Returns an iterator over set bit positions in increasing order starting
/// at the provided bit offset
Returns an iterator over set bit positions in increasing order starting
at the provided bit offset
Returns an iterator over set bit positions in increasing order starting at the provided bit offset
pub fn iter_set_positions_with_offset(
    bytes: &[u8],
    offset: usize,
) -> impl Iterator<Item = usize> + '_ {
    let mut byte_idx = offset >> 3;
    let mut in_progress = bytes.get(byte_idx).cloned().unwrap_or(0);
    let skew = offset & 7;
    in_progress &= 0xFF << skew;
    std::iter::from_fn(move || loop {
        if in_progress != 0 {
            let bit_pos = in_progress.trailing_zeros();
            in_progress ^= 1 << bit_pos;
            return Some((byte_idx << 3) + (bit_pos as usize));
        }
        byte_idx += 1;
        in_progress = *bytes.get(byte_idx)?;
    })
}
pub fn iter_set_positions_with_offset ( bytes : & [ u8 ] , offset : usize , ) -> impl Iterator < Item = usize > + ' _ { let mut byte_idx = offset >> 3 ; let mut in_progress = bytes . get ( byte_idx ) . cloned ( ) . unwrap_or ( 0 ) ; let skew = offset & 7 ; in_progress &= 0xFF << skew ; std :: iter :: from_fn ( move | | loop { if in_progress != 0 { let bit_pos = in_progress . trailing_zeros ( ) ; in_progress ^= 1 << bit_pos ; return Some ( ( byte_idx << 3 ) + ( bit_pos as usize ) ) ; } byte_idx += 1 ; in_progress = * bytes . get ( byte_idx ) ? ; } ) }
Returns an iterator over set bit positions in increasing order starting
at the provided bit offset
Returns an iterator over set bit positions in increasing order starting at the provided bit offset
bytes
&[u8]
offset
usize