Skip to content

Releases: wrenger/bitfield-struct-rs

0.11.0

04 May 13:54
Compare
Choose a tag to compare

Add the option to auto-generate std::hash::Hash as suggested by @freemin7 #62

#[bitfield(u32, hash = true)]
struct MyBitfield {
    data: u16,
    __: u8,
    #[bits(8)]
    extra: u8,
}

The hash implementation ignores any padding, but requires that all fields also implement Hash (similar to Debug).

Thanks to @freemin7 for suggesting this.

0.10.1

26 Jan 11:21
Compare
Choose a tag to compare

Fix clippy unnecessary cast warning #60.
Thanks to @martiege for reporting this.

0.9.5

26 Jan 11:19
Compare
Choose a tag to compare

Fix clippy unnecessary cast warning #60.
Thanks to @martiege for reporting this.

0.9.4

26 Jan 10:56
Compare
Choose a tag to compare

Backport making Copy and Clone optional (#59).

This release is intended to support older rust versions, that lack the const_mut_refs feature.

0.10.0

19 Dec 10:25
Compare
Choose a tag to compare

This release includes an option to disable automatic Copy and Clone implementation. This might be useful when you want to implement your own Clone.

/// We have a custom clone implementation -> opt out
#[bitfield(u64, clone = false)]
struct Full {
    data: u64,
}

impl Clone for Full {
    fn clone(&self) -> Self {
        Self::new().with_data(self.data())
    }
}

impl Copy for Full {}

Thanks to @kevinhartman for implementing this :)

From this release on, the set_<field> and set_<field>_checked setters are const. This is possible due to Rust 1.83.0 stabilizing const mut refs. Consequently, the minimum supported Rust version was bumped to 1.83.0. This also opens the door to a more generic bitfield representation (#7).

0.9.3

03 Dec 20:08
Compare
Choose a tag to compare

This release fixes that defaults for padding were not correctly applied on Msb ordering #57.

Thanks to @gregorygaines for finding and fixing this bug.

0.9.2

15 Oct 14:19
Compare
Choose a tag to compare

This release fixes a clippy warning for certain edge cases #53.

Thanks to @s5suzuki for reporting this.

0.9.1

13 Oct 10:58
Compare
Choose a tag to compare

This release includes some minor fixes, namely #52 (broken defaults for repr) and #51 (documentation for Clone/Copy traits).

Thanks to @hftsai256 and @endrift for finding reporting this.

0.9.0

23 Sep 23:30
Compare
Choose a tag to compare

This release adds new checked setters, which check for integer overflows and return an error instead of panicing (like the normal setters) #49.

#[bitfield(u32)]
struct MyBitfield {
    #[bits(3)]
    number: i32,
    #[bits(29)]
    __: (),
}

assert!(MyBitfield::new().with_number_checked(4).is_err());

Also, the automatic generation of the new function can now also be disable, similar to debug or default #50.

Lastly, the crate now specifies a minimal supported rust version #44.

Thanks to @EngJay, @ultimaweapon, and @DavidAntliff for reporting these issues.

0.8.0

20 Jun 10:19
Compare
Choose a tag to compare

This release adds support for auto-generating the defmt::Format trait (#42):

#[bitfield(u64, defmt = true)]
struct DefmtExample {
    data: u64
}
defmt::println!("{}", DefmtExample::new());

Thanks to @agrif for implementing this.

Also, the auto-trait implementations (Default, Debug, defmt::Format) now support cfg(...) attributes:

#[bitfield(u64, debug = cfg(test), default = cfg(feature = "foo"))]
struct CustomDebug {
    data: u64
}

These cfg attributes are added to the trait implementations, only enabling them if the conditions are met.