bit-iter
Iterate forwards or backwards over the positions of bits set in a word.
A BitIter
may be constructed from any integral value, and returns the
positions of the 1
bits in ascending order.
BitIter
implements DoubleEndedIterator
, so you can iterate over the
positions of the set bits in descending order too.
Example
Output:
Bit 0 is set.
Bit 16 is set.
In reverse order:
Bit 16 is set.
Bit 0 is set.