Macro bitfield::bitfield_constructor
source · macro_rules! bitfield_constructor { (() -> {}; $($rest:tt)*) => { ... }; (@$value:ident; ($($param:ident: $ty:ty,)*) -> {$($stmt:stmt;)*}; $old_ty:ty; impl $_trait:ident$({$($trait_arg:tt)*})?; $($rest:tt)*) => { ... }; (@$value:ident; ($($param:ident: $ty:ty,)*) -> {$($stmt:stmt;)*}; $old_ty:ty; $new_ty:ty; $($rest:tt)*) => { ... }; (@$value:ident; ($($param:ident: $ty:ty,)*) -> {$($stmt:stmt;)*}; $default_ty:ty; $(#[$_:meta])* $(pub)? $(into $_into:ty,)? $_getter:ident, $setter:ident: $($_expr:expr),*; $($rest:tt)* ) => { ... }; (@$value:ident; ($($param:ident: $ty:ty,)*) -> {$($stmt:stmt;)*}; $default_ty:ty; $(#[$_:meta])* $(pub)? $field_type:ty, $(into $_into:ty,)? $_getter:ident, $setter:ident: $($_expr:expr),*; $($rest:tt)* ) => { ... }; (@$value:ident; ($($param:ident: $ty:ty,)*) -> {$($stmt:stmt;)*}; $_:ty;) => { ... }; }
Expand description
Implements an exhaustive constructor function for a bitfield. Should only be called by bitfield!
when using impl new;
§Examples
bitfield_constructor {0; () -> {}; u8; foo1, set_foo1: 2,0; foo2, set_foo2: 7,2}
Generates:
pub fn new(set_foo1: u8, set_foo2: u8) -> Self {
let mut value = Self(0);
value.set_foo1(set_foo1);
value.set_foo2(set_foo2);
value
}