bitit/
lib.rs

1//! # Bitit
2//!
3//! A library for bitwise iteration over Rust integers.
4//!
5//! # Examples
6//! ```
7//! fn main() {
8//!     use bitit::BitIter;
9//!
10//!     let x: u8 = 0b10101100;
11//!
12//!     // Get ones as singular bits:
13//!     print!("1s:\t");
14//!     for b in x.ones() {
15//!         print!("{b} ");
16//!     }
17//!     println!();
18//!
19//!     // Or zeros:
20//!     print!("0s:\t");
21//!     for b in x.zeros() {
22//!         print!("{b} ");
23//!     }
24//!     println!();
25//!
26//!     // Or as indices:
27//!     print!("1s at:\t");
28//!     for i in x.one_indices() {
29//!         print!("{i} ");
30//!     }
31//!     println!();
32//!
33//!     // Or see them all as bools:
34//!     print!("Bits:\t");
35//!     for b in x.bits_rev() {
36//!         // Using `bits_rev` so the bits are printed in the same order as defined.
37//!         print!("{}", b as u8);
38//!     }
39//!     println!();
40//! }
41//! ```
42//!
43//! Output:
44//! ```text
45//! 1s:     4 8 32 128
46//! 0s:     1 2 16 64
47//! 1s at:  2 3 5 7
48//! Bits:   10101100
49//! ```
50
51mod binary;
52mod bit_iter;
53mod iters;
54
55pub use bit_iter::BitIter;