Bit-twiddling can be an error-prone process. Splitbits aims to improve the correctness and legibility of common bit manipulation operations while staying as light-weight as possible.
Here's a simple example (from the README) of extracting two bit fields, a and b, out of a u8:
use splitbits::splitbits;
// Parse the template ("aaabbbbb"), apply it to the input,
// then generate a struct populated with the bit field values.
let fields = splitbits!(0b11110000, "aaabbbbb");
// Single-letter field names,
// generated from the unique letters in the template above.
assert_eq!(fields.a, 0b111);
assert_eq!(fields.b, 0b10000);
While I'm a bit of a macro-hater, they were necessary in order to achieve zero-cost abstraction in this case. I believe I've avoided the characteristic unreadability of most custom macros, and I hope you'll agree.
This project was born out the sheer amount of bit-masking I've need to do for the the NES (Nintendo) emulator that I've been writing. I would sometimes get the bit-twiddling wrong, resulting in a few hours or more of avoidable debugging time. Splitbits has made the process easy and even fun for me, and I'm hoping that you'll experience the same in your low-level projects.
Let me know if you have any questions or feedback!