use core::ops::DerefMut; use core::pin::Pin; use core::task::{Context, Poll};
#[doc(no_inline)] pubuse core::future::Future;
/// An owned dynamically typed [`Future`] for use in cases where you can't /// statically type your result or need to add some indirection. #[cfg(feature = "alloc")] pubtype BoxFuture<'a, T> = Pin<alloc::boxed::Box<dyn Future<Output = T> + Send + 'a>>;
/// `BoxFuture`, but without the `Send` requirement. #[cfg(feature = "alloc")] pubtype LocalBoxFuture<'a, T> = Pin<alloc::boxed::Box<dyn Future<Output = T> + 'a>>;
/// A future which tracks whether or not the underlying future /// should no longer be polled. /// /// `is_terminated` will return `true` if a future should no longer be polled. /// Usually, this state occurs after `poll` (or `try_poll`) returned /// `Poll::Ready`. However, `is_terminated` may also return `true` if a future /// has become inactive and can no longer make progress and should be ignored /// or dropped rather than being `poll`ed again. pubtrait FusedFuture: Future { /// Returns `true` if the underlying future should no longer be polled. fn is_terminated(&self) -> bool;
}
impl<F: FusedFuture + ?Sized + Unpin> FusedFuture for &mut F { fn is_terminated(&self) -> bool {
<F as FusedFuture>::is_terminated(&**self)
}
}
impl<P> FusedFuture for Pin<P> where
P: DerefMut + Unpin,
P::Target: FusedFuture,
{ fn is_terminated(&self) -> bool {
<P::Target as FusedFuture>::is_terminated(&**self)
}
}
mod private_try_future { usesuper::Future;
pubtrait Sealed {}
impl<F, T, E> Sealed for F where F: ?Sized + Future<Output = Result<T, E>> {}
}
/// A convenience for futures that return `Result` values that includes /// a variety of adapters tailored to such futures. pubtrait TryFuture: Future + private_try_future::Sealed { /// The type of successful values yielded by this future type Ok;
/// The type of failures yielded by this future type Error;
/// Poll this `TryFuture` as if it were a `Future`. /// /// This method is a stopgap for a compiler limitation that prevents us from /// directly inheriting from the `Future` trait; in the future it won't be /// needed. fn try_poll(self: Pin<&mutSelf>, cx: &mut Context<'_>) -> Poll<Result<Self::Ok, Self::Error>>;
}
impl<F, T, E> TryFuture for F where
F: ?Sized + Future<Output = Result<T, E>>,
{ type Ok = T; type Error = E;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.