#bits #byte #bool #memory #iterate #struct #iterating

bits128

A struct to iterate over 128 bits by taking only 128 bits

3 releases

0.1.3 Mar 4, 2019
0.1.1 Mar 3, 2019
0.1.0 Mar 3, 2019

#14 in #iterating

21 downloads per month

MIT/Apache

7KB
111 lines

Bits128

Iterating over 128 array of bytes

bits128 provides a struct that let's you use 128 bits while taking only 128 bits in memory.
if you would use something like [bool; 128] it would take 128*8 bits in memory because every bool takes 1 bytes(8bits)
In the future I'll implement an Iterator over the bits so you can iterate over them easily.


lib.rs:

bits128

bits128 provides a struct that let's you use 128 bits while taking only 128 bits in memory.
if you would use something like [bool; 128] it would take 128*8 bits in memory because every bool takes 1 bytes(8bits)
You can easily iterate it by looping over the struct or by manually calling iter() / into_iter()

Examples

let bits = Bits128::from_dec(1337);
for (bit, c) in bits.enumarate() {
    if bit {
        println!("the {}th bit is on", bit);
    ]
}

No runtime deps