core/future/
pending.rs
1use crate::fmt::{self, Debug};
2use crate::future::Future;
3use crate::marker;
4use crate::pin::Pin;
5use crate::task::{Context, Poll};
6
7#[stable(feature = "future_readiness_fns", since = "1.48.0")]
13#[must_use = "futures do nothing unless you `.await` or poll them"]
14pub struct Pending<T> {
15 _data: marker::PhantomData<fn() -> T>,
16}
17
18#[stable(feature = "future_readiness_fns", since = "1.48.0")]
33pub fn pending<T>() -> Pending<T> {
34 Pending { _data: marker::PhantomData }
35}
36
37#[stable(feature = "future_readiness_fns", since = "1.48.0")]
38impl<T> Future for Pending<T> {
39 type Output = T;
40
41 fn poll(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<T> {
42 Poll::Pending
43 }
44}
45
46#[stable(feature = "future_readiness_fns", since = "1.48.0")]
47impl<T> Debug for Pending<T> {
48 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
49 f.debug_struct("Pending").finish()
50 }
51}
52
53#[stable(feature = "future_readiness_fns", since = "1.48.0")]
54impl<T> Clone for Pending<T> {
55 fn clone(&self) -> Self {
56 pending()
57 }
58}