macro_rules! bitfield_debug {
(struct $name:ident; $($rest:tt)*) => { ... };
($debug_struct:ident, $self:ident, #[$attribute:meta] $($rest:tt)*) => { ... };
($debug_struct:ident, $self:ident, pub $($rest:tt)*) => { ... };
($debug_struct:ident, $self:ident, _, $setter:tt: $($exprs:expr),*; $($rest:tt)*) => { ... };
($debug_struct:ident, $self:ident, $type:ty; $($rest:tt)*) => { ... };
($debug_struct:ident, $self:ident, $getter:ident, $setter:tt: $msb:expr, $lsb:expr, $count:expr;
$($rest:tt)*) => { ... };
($debug_struct:ident, $self:ident, $getter:ident, $setter:tt: $($exprs:expr),*; $($rest:tt)*) => { ... };
($debug_struct:ident, $self:ident, from into $into:ty, $($rest:tt)*) => { ... };
($debug_struct:ident, $self:ident, into $into:ty, $($rest:tt)*) => { ... };
($debug_struct:ident, $self:ident, $type:ty, $($rest:tt)*) => { ... };
($debug_struct:ident, $self:ident, ) => { ... };
}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);
}