blessed-rs
blessed-rs copied to clipboard
Recommend a bit-field crate
I think a lot of people coming from C or C++ will expect some sort of support for structs with bit-fields. They're useful when writing drivers, emulators, and low-level networking code. The bitflags crate already recommended can be used to approximate bit-fields of 1-bit but doesn't work for any other case.
From a quick glance at lib.rs, here are the most popular options, most of which are proc-macros:
- bitfield
- deku, which uses bitvec
- bitfield-struct
- modular-bitfield
- bitbybit
- bilge
- bitfields
The only ones I've tried are deku and bitbybit. I found deku to be pretty slow in terms of compile-time because of the dependency tree. It also generates a lot of assembly (which may mean it's slower but I haven't benched). I really liked bitbybit.