use pin_project_lite::pin_project;
use std::{
future::Future,
pin::Pin,
task::{Context, Poll},
};
pin_project! {
#[derive(Debug, Clone)]
pub struct DroppableFuture<T> {
#[pin] future: T
}
}
impl<T: Future> DroppableFuture<T> {
pub fn new(future: T) -> Self {
Self { future }
}
pub fn into_inner(self) -> T {
self.future
}
}
impl<F: Future> Future for DroppableFuture<F> {
type Output = F::Output;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
self.project().future.poll(cx)
}
}