fire_stream/standalone_util/
pinned_future.rs

1use std::pin::Pin;
2use std::future::Future;
3use std::task::{Context, Poll};
4
5pub struct PinnedFuture<'a, O> {
6	inner: Pin<Box<dyn Future<Output=O> + Send + 'a>>
7}
8
9impl<'a, O> PinnedFuture<'a, O> {
10	pub fn new<F>(future: F) -> Self
11	where F: Future<Output=O> + Send + 'a {
12		Self {
13			inner: Box::pin(future)
14		}
15	}
16}
17
18impl<O> Future for PinnedFuture<'_, O> {
19	type Output = O;
20	fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
21		self.get_mut().inner.as_mut().poll(cx)
22	}
23}