pub fn bits_iter<T>(value: T) -> impl Iterator<Item = u32> where
T: PartialEq + From<u8> + Shl<u32, Output = T> + Not<Output = T> + BitAndAssign + TrailingZeros,
Expand description
Returns an iterator over the set bits of value
.
Examples
use kernel::bits_iter;
let mut iter = bits_iter(5usize);
assert_eq!(iter.next().unwrap(), 0);
assert_eq!(iter.next().unwrap(), 2);
assert!(iter.next().is_none());
use kernel::bits_iter;
fn print_bits(x: usize) {
for bit in bits_iter(x) {
pr_info!("{}\n", bit);
}
}