# ferro_thread_local

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-system/macro-ferro_thread_local/

**macro** · [`ferroui-system`](/docs/0.5.0/api/ferroui-system/) · v0.5.0

```rust
macro_rules! ferro_thread_local
```

Declares thread-local variables: `std::thread_local!` on targets with
thread-local statics, a slot of the table of the thread on Android (see
the module).

```
use std::cell::{Cell, RefCell};

ferroui_system::ferro_thread_local! {
    static COUNT: Cell<u32> = const { Cell::new(0) };
    static NAMES: RefCell<Vec<String>> = RefCell::new(Vec::new());
}

COUNT.set(COUNT.get() + 1);
NAMES.with_borrow_mut(|names| names.push("one".to_owned()));
assert_eq!(COUNT.get(), 1);
```

New code of the workspace declares its thread-local variables with this
macro and never with `thread_local!` (the conventions job checks it).

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/ferro_thread_local.rs#L80)

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
