//! Definition of the `Option` (optional step) combinator
use core::pin::Pin; use futures_core::future::{FusedFuture, Future}; use futures_core::task::{Context, Poll}; use pin_project_lite::pin_project;
pin_project! { /// A future representing a value which may or may not be present. /// /// Created by the [`From`] implementation for [`Option`](std::option::Option). /// /// # Examples /// /// ``` /// # futures::executor::block_on(async { /// use futures::future::OptionFuture; /// /// let mut a: OptionFuture<_> = Some(async { 123 }).into(); /// assert_eq!(a.await, Some(123)); /// /// a = None.into(); /// assert_eq!(a.await, None); /// # }); /// ``` #[derive(Debug, Clone)] #[must_use = "futures do nothing unless you `.await` or poll them"] pubstruct OptionFuture<F> { #[pin]
inner: Option<F>,
}
}
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.