bitfield_debug!() { /* proc-macro */ }
Expand description
Generates a fmt::Debug
implementation.
This macros must be called from a impl Debug for ...
block. It will generate the fmt
method.
In most of the case, you will not directly call this macros, but use bitfield
.
The syntax is struct TheNameOfTheStruct;
followed by the syntax of bitfield_fields
.
The write-only fields are ignored.
§Example
ⓘ
struct FooBar(u32);
bitfield_bitrange!{struct FooBar(u32)}
impl FooBar{
bitfield_fields!{
u32;
field1, _: 7, 0;
field2, _: 31, 24;
}
}
impl std::fmt::Debug for FooBar {
bitfield_debug!{
struct FooBar;
field1, _: 7, 0;
field2, _: 31, 24;
}
}
fn main() {
let foobar = FooBar(0x11223344);
println!("{:?}", foobar);
}