0.6.0
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.