futures_util/async_await/
pending.rs1use core::pin::Pin;
2use futures_core::future::Future;
3use futures_core::task::{Context, Poll};
4
5#[macro_export]
16macro_rules! pending {
17    () => {
18        $crate::__private::async_await::pending_once().await
19    };
20}
21
22#[doc(hidden)]
23pub fn pending_once() -> PendingOnce {
24    PendingOnce { is_ready: false }
25}
26
27#[allow(missing_debug_implementations)]
28#[doc(hidden)]
29pub struct PendingOnce {
30    is_ready: bool,
31}
32
33impl Future for PendingOnce {
34    type Output = ();
35    fn poll(mut self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Self::Output> {
36        if self.is_ready {
37            Poll::Ready(())
38        } else {
39            self.is_ready = true;
40            Poll::Pending
41        }
42    }
43}