bitfield-struct
Struct-like procedural macro for bitfields.
0.13.0
22M downloads/mo
#1996 most downloaded on crates.io
wrenger/bitfield-struct-rs
What this package is like to depend on
Last release 4 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
3 releases in the last 12 months
see the full history below
Release timeline
42 releases · Dec 2021 to Apr 2026Releases
latest 42-
0.13.004 Apr 2026Release notes
Open source →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, }
-
0.12.127 Oct 2025 -
0.12.023 Oct 2025Release notes
Open source →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_bitsfunction 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.
-
0.11.004 May 2025Release notes
Open source →Add the option to auto-generate
std::hash::Hashas 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 toDebug).Thanks to @freemin7 for suggesting this.
-
0.10.126 Jan 2025Release notes
Open source → -
0.10.019 Dec 2024Release notes
Open source →This release includes an option to disable automatic
CopyandCloneimplementation. This might be useful when you want to implement your ownClone./// 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>andset_<field>_checkedsetters areconst. 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.526 Jan 2025Release notes
Open source → -
0.9.426 Jan 2025Release notes
Open source →Backport making
CopyandCloneoptional (#59).This release is intended to support older rust versions, that lack the
const_mut_refsfeature. -
0.9.303 Dec 2024Release notes
Open source →This release fixes that defaults for padding were not correctly applied on
Msbordering #57.Thanks to @gregorygaines for finding and fixing this bug.
-
0.9.215 Oct 2024Release notes
Open source →This release fixes a clippy warning for certain edge cases #53.
Thanks to @s5suzuki for reporting this.
-
0.9.113 Oct 2024Nothing published for this version
-
0.9.023 Sep 2024Nothing published for this version
-
0.8.020 Jun 2024Nothing published for this version
-
0.7.007 Jun 2024Nothing published for this version
-
0.6.223 May 2024Nothing published for this version
-
0.6.114 Apr 2024Nothing published for this version
-
0.6.016 Feb 2024Nothing published for this version
-
0.5.610 Dec 2023Nothing published for this version
-
0.5.511 Nov 2023Nothing published for this version
-
0.5.431 Aug 2023Nothing published for this version
-
0.5.330 Jul 2023Nothing published for this version
-
0.5.227 Jun 2023Nothing published for this version
-
0.5.127 Jun 2023Nothing published for this version
-
0.5.027 Jun 2023 withdrawnNothing published for this version
-
0.4.405 Jun 2023Nothing published for this version
-
0.4.326 May 2023Nothing published for this version
-
0.4.217 May 2023Nothing published for this version
-
0.4.131 Mar 2023Nothing published for this version
-
0.4.031 Mar 2023 withdrawnNothing published for this version
-
0.3.224 Jan 2023Nothing published for this version
-
0.3.114 Jan 2023Nothing published for this version
-
0.3.014 Jan 2023Nothing published for this version
-
0.2.023 Dec 2022Nothing published for this version
-
0.1.807 Dec 2022Nothing published for this version
-
0.1.705 May 2022Nothing published for this version
-
0.1.608 Apr 2022Nothing published for this version
-
0.1.519 Mar 2022Nothing published for this version
-
0.1.412 Jan 2022Nothing published for this version
-
0.1.312 Jan 2022Nothing published for this version
-
0.1.209 Jan 2022Nothing published for this version
-
0.1.128 Dec 2021Nothing published for this version
-
0.1.021 Dec 2021Nothing published for this version