use crate::lib::future::Future; use crate::lib::marker::Unpin; use crate::lib::pin::Pin; use crate::lib::task::{Context, Poll}; // Replace usage of this with std::future::poll_fn once it stabilizes pub struct PollFn { f: F, } impl Unpin for PollFn {} pub fn poll_fn(f: F) -> PollFn where F: FnMut(&mut Context<'_>) -> Poll, { PollFn { f } } impl Future for PollFn where F: FnMut(&mut Context<'_>) -> Poll, { type Output = T; fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { (&mut self.f)(cx) } }