Macro fluid_let::fluid_set

source ·
macro_rules! fluid_set {
    ($variable:expr, $value:expr) => { ... };
}
Expand description

Binds a value to a dynamic variable.

Examples

If you do not need to explicitly delimit the scope of dynamic assignment then you can use fluid_set! to assign a value until the end of the current scope:

use fluid_let::{fluid_let, fluid_set};

fluid_let!(static ENABLED: bool);

fn some_function() {
    fluid_set!(ENABLED, true);

    // function body
}

This is effectively equivalent to writing

fn some_function() {
    ENABLED.set(true, || {
        // function body
    });
}

See also crate-level documentation for usage examples.