Skip to content

0.12.0

Choose a tag to compare

@wrenger wrenger released this 23 Oct 16:16
· 7 commits to main since this release

This release contains a few fixes for #64 and #68, as well as optional support for the binrw traits #65 from @Maccraft123.

Additionally, it introduces a small new macro for generating the from_bits/into_bits function for enums:

use bitfield_struct::bitenum;

#[bitenum]
#[repr(u8)]
#[derive(Debug, PartialEq, Eq)]
enum MyEnum {
    #[fallback]
    A = 0,
    B = 1,
    C = 2,
}

assert_eq!(MyEnum::from_bits(1), MyEnum::B);
assert_eq!(MyEnum::C.into_bits(), 2);

#[bitfield(u8)]
struct Test {
    #[bits(8)]
    value: MyEnum,
}

Thanks to @MolotovCherry and @xTachyon for reporting these issues.