macro_rules! coroutine_local {
    (static $NAME:ident : $t:ty = $e:expr) => { ... };
}
Expand description

A macro to create a static of type LocalKey

This macro is intentionally similar to the thread_local!, and creates a static which has a with method to access the data on a coroutine.

The data associated with each coroutine local is per-coroutine, so different coroutines will contain different values. for example:

    cogo::coroutine_local!(static FOO: i32 = 3);

    // can only be called in coroutine context
    FOO.with(|f| {
        assert_eq!(*f, 3);
    });