async_coroutine 0.2.0

A coroutine implementation based on Rust's async/await syntax.
Documentation
use std::{
    future::Future,
    pin::Pin,
    task::{Context, Poll},
};

pub async fn yield_now() {
    YieldNow(false).await
}

struct YieldNow(bool);

impl Future for YieldNow {
    type Output = ();

    fn poll(mut self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Self::Output> {
        if !self.0 {
            self.0 = true;
            Poll::Pending
        } else {
            Poll::Ready(())
        }
    }
}