# Macro std::thread_local 1.0.0 [−] [src]

    macro_rules! thread_local {
        () => { ... };
        ($(#[$attr:meta])* static $name:ident: $t:ty = $init:expr; $($rest:tt)*) => { ... };
        ($(#[$attr:meta])* static $name:ident: $t:ty = $init:expr) => { ... };
        ($(#[$attr:meta])* pub static $name:ident: $t:ty = $init:expr; $($rest:tt)*) => { ... };
        ($(#[$attr:meta])* pub static $name:ident: $t:ty = $init:expr) => { ... };
    }

Declare a new thread local storage key of type `std::thread::LocalKey`.

# Syntax

The macro wraps any number of static declarations and makes them thread local. Each static may be public or private, and attributes are allowed. 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

See LocalKey documentation for more information.

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result
+
  Collapse/expand all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)