use std::{
future::Future,
pin::Pin,
task::{Context, Poll},
};
#[derive(Debug)]
pub(crate) struct MaybeFuture<T> {
pub inner: Option<T>,
}
impl<T> Default for MaybeFuture<T> {
fn default() -> Self {
MaybeFuture { inner: None }
}
}
impl<T: Future + Unpin> Future for MaybeFuture<T> {
type Output = T::Output;
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
match self.inner {
Some(ref mut t) => Pin::new(t).poll(cx),
None => Poll::Pending,
}
}
}