use std::{
future::Future,
pin::Pin,
task::{Context, Poll},
};
use pin_project::pin_project;
pub fn poll<F: Future>(future: F) -> PollOnce<F> {
PollOnce::new(future)
}
#[must_use = "futures do nothing unless you `.await` or poll them"]
#[pin_project]
#[derive(Debug)]
pub struct PollOnce<F: Future>(#[pin] F);
impl<F: Future> PollOnce<F> {
pub fn new(future: F) -> Self {
Self(future)
}
}
impl<F: Future> Future for PollOnce<F> {
type Output = Poll<F::Output>;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
Poll::Ready(self.project().0.poll(cx))
}
}