Bitstructs
bitstructs is a library for defining type-safe bitfield structs that can be used in both std and no_std environments.
Features
- Type-safe bit operations
- Simple to use and highly flexible
- Supports both
no_stdandstd - Implemented using proc-macros with no additional runtime code
Example
Here is a simple example of using bitstructs.
use ;
bitstruct_cow!
}
let mut value = new;
assert_eq!;
value.set_a;
unsafe ;
value.set_c;
assert_eq!;
By default, the library uses LSB0 and little-endian mode. To use MSB0 and big-endian mode, add #[bitstruct_repr(MSB0)] to the struct.
use ;
bitstruct_cow!
}
let mut value = new;
assert_eq!;
value.set_a;
unsafe ;
value.set_c;
assert_eq!;
Documentation
For more information, please refer to the documentation.
Contribution
Contributions are welcome! Please open an issue or submit a pull request on GitHub.