fluid-let icon indicating copy to clipboard operation
fluid-let copied to clipboard

Attribute macro

Open ilammy opened this issue 4 years ago • 0 comments

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?

ilammy avatar Oct 12 '21 12:10 ilammy