macro_rules! impl_flag_trait {
($name:ident, $type:ty) => { ... };
}Expand description
impl_flag_trait! - The Master Flag Factory.
This macro is a “High-Level Orchestrator.” It does three critical things:
- Defines the Schema: Creates a private-field struct with essential derives.
- Injects Utility: Calls the “Boilerplate Assassins” (new, default, from, value).
- Fulfills the Contract: Implements the
Flagtrait using direct bitwise masking.
§Logic Style: Masking
Unlike the index-based shifting (1 << i), this macro assumes the Value passed in
is a pre-calculated mask. This is highly optimized for performance.
§Arguments
$name- The identifier for your new Type (e.g.,NetworkFlags).$type- The underlying integer width (e.g.,u8,u16,u32,u64).