Skip to content

0.6.0

Compare
Choose a tag to compare
@wrenger wrenger released this 16 Feb 22:43
· 34 commits to main since this release

This release added the auto-generation of the (from|into)_bits conversion functions for bitfields (which can be disabled by [bitfield(u8, conversion = false)]).

Together with the laxer type requirements for the conversion functions, this makes it simple to nest bitfields.

#[bitfield(u8)]
#[derive(PartialEq)]
struct Child {
    contents: u8,
}
#[bitfield(u16)]
#[derive(PartialEq)]
struct Parent {
    #[bits(8)]
    child: Child,
    other: u8,
}
let child = Child::new().with_contents(0xff);
let parent = Parent::new().with_child(child);
assert_eq!(child.into_bits(), 0xff);
assert_eq!(parent.into_bits(), 0xff);

Thanks to @Frostie314159 for implementing this feature and to @akauppi and @deeglaze for additional fixes.