[−][src]Macro threadstack::push_thread_stack_value
Push a new value on the top of the threadstack. this value becomes
the value that will be returned by clone_thread_stack_value
and
that let_ref_thread_stack_value!
will create a reference to. Can
only be invoked inside a function, and the effect will last until
the end of the current scope. Note that pushing new values will
panic if you go beyond the compile time configured maximum
threadstack size. The assumption is that threadstacks are mostly
used for infrequently set context data, or configuration settings
that would otherwise be global variables.
use threadstack::*; declare_thread_stacks!( FOO: String = String::from("hello world"); ); assert!(clone_thread_stack_value(&FOO) == "hello world"); { push_thread_stack_value!("hello universe".into(), FOO); assert!(clone_thread_stack_value(&FOO) == "hello universe"); } assert!(clone_thread_stack_value(&FOO) == "hello world");