[−][src]Macro async_std::task_local
Declares task-local values.
The macro wraps any number of static declarations and makes them task-local. Attributes and visibility modifiers are allowed.
Each declared value is of the accessor type LocalKey
.
Examples
use std::cell::Cell; use async_std::task; use async_std::prelude::*; task_local! { static VAL: Cell<u32> = Cell::new(5); } task::block_on(async { let v = VAL.with(|c| c.get()); assert_eq!(v, 5); });