modular-bitfield icon indicating copy to clipboard operation
modular-bitfield copied to clipboard

Add ::BITS or ::BYTES constant for generated structs

Open bramp opened this issue 3 years ago • 0 comments

It would be helpful to have a constant on each bitfield struct that indicates its length, for example

#[bitfield]
pub struct MyFourBytes {
    a: B1,
    b: B3,
    c: B4,
    d: B24,
}

should have:

MyFourBytes::BITS; // equals 32

So I can easily determine the length of the struct, when reading/creating byte arrays.

bramp avatar May 28 '21 18:05 bramp