Macro std::thread_local 1.0.0[−][src]
macro_rules! thread_local {
() => { ... };
($(#[$attr : meta]) * $vis : vis static $name : ident : $t : ty = const
{ $init : expr } ; $($rest : tt) *) => { ... };
($(#[$attr : meta]) * $vis : vis static $name : ident : $t : ty = const
{ $init : expr }) => { ... };
($(#[$attr : meta]) * $vis : vis static $name : ident : $t : ty = $init : expr
; $($rest : tt) *) => { ... };
($(#[$attr : meta]) * $vis : vis static $name : ident : $t : ty = $init :
expr) => { ... };
}
Expand description
声明一个新的 std::thread::LocalKey
类型的线程本地存储密钥。
Syntax
宏可以包装任意数量的静态声明,并使它们成为局部线程。
允许每个静态的公开和属性。Example:
use std::cell::RefCell;
thread_local! {
pub static FOO: RefCell<u32> = RefCell::new(1);
#[allow(unused)]
static BAR: RefCell<f32> = RefCell::new(1.0);
}
Run有关更多信息,请参见 LocalKey
文档。