fluid-let
fluid-let copied to clipboard
Attribute macro
I think it would be cool to write
#[fluid]
pub static VARIABLE: Type = initial_value;
instead of somewhat awkward
fluid_let! {
pub static VARIABLE: Type = initial_value;
}
This will have to be a separate (and probably optional) crate, because that's how procedural macros work.
Ideally, this should be a proper generic:
pub static VARIABLE_A: DynamicVariable<Type> = DynamicVariable::new(initial_value);
pub static VARIABLE_B: DynamicVariable<Type> = DynamicVariable::uninitialized();
But we need these statics to be thread-local, and thread_local! macro is the only way to declare thread-local variables. At least, that was the case two years ago when I started this thing. Maybe there is a different way now?