Crate bit_iter[][src]

Expand description

Iterate over the bits set in a word.

A BitIter may be constructed from any integral value.

Example

fn main() {
    use bit_iter::*;

    let x : u32 = 0x10001;

    for b in BitIter::from(x) {
        println!("Bit {} is set.", b);
    }

    println!("In reverse order:");

    for b in BitIter::from(x).rev() {
        println!("Bit {} is set.", b);
    }
}

Output:

Bit 0 is set.
Bit 16 is set.
In reverse order:
Bit 16 is set.
Bit 0 is set.

Structs

BitIter

An iterator which returns the positions of the set bits in an integral value.