NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
crates.io · #2045 most downloaded on crates.io
Struct-like procedural macro for bitfields.
Last release 6 months ago
04 Apr 2026
Release timing varies
gaps range from 2 weeks to 6 months
Some releases are documented
notes for 10 of 40 stable releases
2 versions withdrawn
withdrawn after publishing
5 years old
42 releases · first in 2021
One column per quarter.
This release adds support for const generics.
This release adds support for const generics.
Bitfields can now use const generics directly. Just declare them on the struct as usual:
use bitfield_struct::bitfield;
#[bitfield(u16)]
#[derive(PartialEq, Eq)]
struct Packet<const VERSION: u8> {
#[bits(4)]
tag: u8,
#[bits(12)]
payload: u16,
}Support #[cfg(...)] on bit enum variants
Support #[cfg(...)] on bit enum variants
This release contains a few fixes for #64 and #68 , as well as optional support for the binrw traits #65 from @Maccraft123 .
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.
Add the option to auto-generate std::Hash as suggested by @freemin7 #62
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.
Fix clippy unnecessary cast warning #60 . Thanks to @martiege for reporting this.
This release includes an option to disable automatic Copy and Clone implementation. This might be useful when you want to implement your own Clone .
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).
Fix clippy unnecessary cast warning #60 . Thanks to @martiege for reporting this.
Backport making Copy and Clone optional ( #59 ).
Backport making Copy and Clone optional (#59).
This release is intended to support older rust versions, that lack the const_mut_refs feature.
This release fixes that defaults for padding were not correctly applied on Msb ordering #57 .
This release fixes that defaults for padding were not correctly applied on Msb ordering #57.
Thanks to @gregorygaines for finding and fixing this bug.
This release fixes a clippy warning for certain edge cases #53 .
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Your coding agent can read these notes before it upgrades. Set up the MCP server →