Macro cmd_lib::tls_set

source ·
macro_rules! tls_set {
    ($var:ident, |$v:ident| $($var_update:tt)*) => { ... };
}
Expand description

Set the value of a thread local storage variable.

tls_init!(screen_buffer, String, "".to_string());
tls_set!(screen_buffer, |s| s.push_str(changes));

tls_init!(use_color, bool, true); // true if we use color, false if not
fn toggle_color() {
    tls_set!(use_color, |x| *x = !*x);
    // redraw_screen();
}