use std::{
future::Future,
pin::Pin,
task::{Context, Poll},
};
pub struct YieldOnce(bool);
pub fn yield_once() -> YieldOnce {
YieldOnce(false)
}
impl Future for YieldOnce {
type Output = ();
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> {
if self.0 {
Poll::Ready(())
} else {
self.0 = true;
cx.waker().wake_by_ref(); Poll::Pending }
}
}