Skip to main content

feature_gate

Macro feature_gate 

Source
macro_rules! feature_gate {
    ($license:expr, $feature:expr, $enabled:block) => { ... };
    ($license:expr, $feature:expr, $enabled:block else $disabled:block) => { ... };
}
Expand description

Feature gate macro for conditional code execution.

§Example

let license = require_valid_license!("license.lic");

feature_gate!(license, "premium", {
    // This code only runs if "premium" feature is licensed
    enable_premium_features();
});

feature_gate!(license, "enterprise", {
    enable_sso();
    enable_audit_logging();
} else {
    show_upgrade_prompt();
});