waker_fn in std::task - Rust
Description: Converts a closure into a `Waker`.

## waker_fn

# Function waker_fn

Source

    pub fn waker_fn<F>(f: F) -> Wakerwhere
        F: Fn() + Send + Sync + 'static,

🔬This is a nightly-only experimental API. (`waker_fn` #149580)
Available on `target_has_atomic=ptr` only.
Expand description

Converts a closure into a `Waker`.

The closure gets called every time the waker is woken.

## §Examples

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

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

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