Robbepop / modular-bitfield

Macro to generate bitfields for structs that allow for modular use of enums.
Apache License 2.0
155 stars 40 forks source link

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

Open bramp opened 3 years ago

bramp commented 3 years ago

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.