Macro bitfield::bitfield
[−]
[src]
macro_rules! bitfield { ($(#[$attribute:meta])* pub struct $($rest:tt)*) => { ... }; ($(#[$attribute:meta])* struct $($rest:tt)*) => { ... }; ($(#[$attribute:meta])* ($($vis:tt)*) struct $name:ident([$t:ty]); impl Debug; $($rest:tt)*) => { ... }; ($(#[$attribute:meta])* ($($vis:tt)*) struct $name:ident([$t:ty]); $($rest:tt)*) => { ... }; ($(#[$attribute:meta])* ($($vis:tt)*) struct $name:ident(MSB0 [$t:ty]); impl Debug; $($rest:tt)*) => { ... }; ($(#[$attribute:meta])* ($($vis:tt)*) struct $name:ident(MSB0 [$t:ty]); $($rest:tt)*) => { ... }; ($(#[$attribute:meta])* ($($vis:tt)*) struct $name:ident($t:ty); impl Debug; $($rest:tt)*) => { ... }; ($(#[$attribute:meta])* ($($vis:tt)*) struct $name:ident($t:ty); $($rest:tt)*) => { ... }; }
Combines bitfield_struct
and bitfield_fields
.
The syntax of this macro is the syntax of bitfield_struct
, a semicolon, and then the syntax
of bitfield_fields
.
If you put impl Debug;
after the first semicolon, an implementation of fmt::Debug
will be
generated with the bitfield_debug
macro.
The difference with calling those macros separately is that bitfield_fields
is called
from an appropriate impl
block. If you use the non-slice form of bitfield_struct
, the
default type for bitfield_fields
will be set to the wrapped fields.
See the documentation of these macros more information on their respective syntax.
Example
bitfield!{ pub struct BitField1(u16); impl Debug; // The fields default to u16 field1, set_field1: 10, 0; pub field2, _ : 12, 3; }