Bitfield Struct
Procedural macro for bitfields that allows specifying bitfields as structs.
As this library provides a procedural macro, it has no runtime dependencies and works for no-std
.
Usage
Add this to your Cargo.toml
:
[]
= "0.1"
Example
The macro generates three accessor functions for each field. Each accessor also inherits the documentation of its field.
The signatures for addr
, for example, are:
// generated struct
;
// generated trait implementations
This generated bitfield can then be used as follows.
let mut pte = new
.with_addr
.with_size
.with_present
.with_negative;
println!;
assert!;
pte.set_size;
let value: u64 = pte.into;
println!;