hyper_util/common/
future.rs1use std::{
2 future::Future,
3 pin::Pin,
4 task::{Context, Poll},
5};
6
7pub(crate) fn poll_fn<T, F>(f: F) -> PollFn<F>
9where
10 F: FnMut(&mut Context<'_>) -> Poll<T>,
11{
12 PollFn { f }
13}
14
15pub(crate) struct PollFn<F> {
16 f: F,
17}
18
19impl<F> Unpin for PollFn<F> {}
20
21impl<T, F> Future for PollFn<F>
22where
23 F: FnMut(&mut Context<'_>) -> Poll<T>,
24{
25 type Output = T;
26
27 fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
28 (self.f)(cx)
29 }
30}