futures_util/async_await/
poll.rs1use crate::future::FutureExt;
2use core::pin::Pin;
3use futures_core::future::Future;
4use futures_core::task::{Context, Poll};
5
6#[macro_export]
17macro_rules! poll {
18 ($x:expr $(,)?) => {
19 $crate::__private::async_await::poll($x).await
20 };
21}
22
23#[doc(hidden)]
24pub fn poll<F: Future + Unpin>(future: F) -> PollOnce<F> {
25 PollOnce { future }
26}
27
28#[allow(missing_debug_implementations)]
29#[doc(hidden)]
30pub struct PollOnce<F: Future + Unpin> {
31 future: F,
32}
33
34impl<F: Future + Unpin> Future for PollOnce<F> {
35 type Output = Poll<F::Output>;
36 fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
37 Poll::Ready(self.future.poll_unpin(cx))
38 }
39}