yield-return 0.2.0

Implement a coroutine like C#'s `yield return` using Rust's `async`, `await`.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use std::{
    sync::{Arc, OnceLock},
    task::{Wake, Waker},
};

struct NoopWake;
impl Wake for NoopWake {
    fn wake(self: Arc<Self>) {}
    fn wake_by_ref(self: &Arc<Self>) {}
}

// TODO: Remove this function when `std::task::Waker::noop` is stabilized.
pub fn noop_waker() -> Waker {
    static WAKER: OnceLock<Arc<NoopWake>> = OnceLock::new();
    WAKER.get_or_init(|| Arc::new(NoopWake)).clone().into()
}