use core::{
future::Future,
pin::Pin,
task::{Context, Poll},
};
#[derive(Debug)]
#[must_use]
pub struct DoYield {
done: bool,
}
impl Future for DoYield {
type Output = ();
fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<()> {
if self.done {
Poll::Ready(())
} else {
self.done = true;
cx.waker().wake_by_ref();
Poll::Pending
}
}
}
pub fn do_yield() -> DoYield {
DoYield { done: false }
}