bitbybit 2.0.1

Efficient implementation of bit-fields where several numbers are packed within a larger number and bit-enums. Useful for drivers, so it works in no_std environments
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use bitbybit::bitfield;

#[bitfield(u32, default = 0, forbid_overlaps)]
struct Test {
    #[bits(8..=15, rw)]
    foo: u8,
    #[bits(0..=7, rw)]
    bar: u8,
}

fn main() {
    Test::builder().with_foo(1).build();
    Test::builder().with_bar(1).build();
    Test::builder().with_bar(1).with_foo(1).build();
    Test::builder().with_bar(1).with_foo(1).with_bar(2).build();
}