local_waker_fn in alloc::task - Rust
Description: Converts a closure into a `LocalWaker`.

## local_waker_fn

# Function local_waker_fn

Source

    pub fn local_waker_fn<F: Fn() + Send + Sync + 'static>(f: F) -> LocalWaker

🔬This is a nightly-only experimental API. (`waker_fn` #149580)
Expand description

Converts a closure into a `LocalWaker`.

The closure gets called every time the local waker is woken.

## §Examples

    #![feature(local_waker)]
    #![feature(waker_fn)]
    use std::task::local_waker_fn;

    let waker = local_waker_fn(|| println!("woken"));

    waker.wake_by_ref(); // Prints "woken".
    waker.wake();        // Prints "woken".