Skip to content

0.5.2

Compare
Choose a tag to compare
@wrenger wrenger released this 27 Jun 20:58
· 63 commits to main since this release

Add the option to opt out from implementing the Default trait similar to the fmt::Debug trait.

#[bitfield(u64, debug = false, default = false)]
struct CustomDebug {
    data: u64
}
impl fmt::Debug for CustomDebug {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "0x{:x}", self.data())
    }
}
impl Default for CustomDebug {
    fn default() -> Self {
        Self(123) // note: you can also use `#[bits(64, default = 123)]`
    }
}

let val = CustomDebug::default();
println!("{val:?}")