FeatureFlags

Derive Macro FeatureFlags 

Source
#[derive(FeatureFlags)]
{
    // Attributes available to this derive:
    #[flag]
    #[feature_flags]
}
Expand description

Derive macro for the FeatureFlags trait

Generates implementations for is_enabled(), set(), and all_flags() methods. Also generates a Default implementation using the specified defaults.

§Attributes

  • #[flag(default = true)] - Set default value (defaults to false)

§Example

use tui_dispatch::FeatureFlags;

#[derive(FeatureFlags)]
struct Features {
    #[flag(default = false)]
    new_search_ui: bool,

    #[flag(default = true)]
    vim_bindings: bool,
}

let mut features = Features::default();
assert!(!features.new_search_ui);
assert!(features.vim_bindings);

features.enable("new_search_ui");
assert!(features.new_search_ui);