Skip to main content

bitfield_impl

Macro bitfield_impl 

Source
macro_rules! bitfield_impl {
    (Debug for struct $name:ident([$t:ty]); $($rest:tt)*) => { ... };
    (Debug for struct $name:ident($t:ty); $($rest:tt)*) => { ... };
    (BitAnd for struct $name:ident([$t:ty]); $($rest:tt)*) => { ... };
    (BitAnd for struct $name:ident($t:ty); $($rest:tt)*) => { ... };
    (BitOr for struct $name:ident([$t:ty]); $($rest:tt)*) => { ... };
    (BitOr for struct $name:ident($t:ty); $($rest:tt)*) => { ... };
    (BitXor for struct $name:ident([$t:ty]); $($rest:tt)*) => { ... };
    (BitXor for struct $name:ident($t:ty); $($rest:tt)*) => { ... };
    (@bitwise $bitwise:ident $func:ident $bitwise_assign:ident $func_assign:ident $name:ident([$t:ty]) $op:tt) => { ... };
    (@bitwise $bitwise:ident $func:ident $bitwise_assign:ident $func_assign:ident $name:ident($t:ty) $op:tt) => { ... };
    (@mutate $self:ident $rhs:ident $op:tt) => { ... };
    (new for struct $name:ident([$t:ty]); $($rest:tt)*) => { ... };
    (new for struct $name:ident($t:ty); $($rest:tt)*) => { ... };
    (new{$new:ident ($($setter_name:ident: $setter_type:ty),*$(,)?)} for struct $name:ident([$t:ty]); $($rest:tt)*) => { ... };
    (new{$new:ident ($($setter_name:ident: $setter_type:ty),*$(,)?)} for struct $name:ident($t:ty); $($rest:tt)*) => { ... };
    ($macro:ident for struct $name:ident $($rest:tt)*) => { ... };
}
Expand description

Generates and dispatches trait implementations for a struct

This must be called outside of any impl block.

The syntax is TheNameOfTheTrait for struct TheNameOfTheStruct(TheInnerType); followed by the syntax of bitfield_fields.

Supported traits:

  • Debug
  • BitAnd
  • BitOr
  • BitXor

Additional derivations:

  • new
    • Creates a constructor, including parameters for all fields with a setter