You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
async-std/src/future/mod.rs

43 lines
932 B
Rust

//! Asynchronous values.
#[doc(inline)]
pub use std::future::Future;
/// Never resolves to a value.
///
/// # Examples
/// ```
/// # #![feature(async_await)]
/// use async_std::future::pending;
/// use async_std::prelude::*;
/// use std::time::Duration;
///
/// # async_std::task::block_on(async {
/// let dur = Duration::from_secs(1);
/// assert!(pending::<()>().timeout(dur).await.is_err());
/// # })
/// ```
pub async fn pending<T>() -> T {
futures::future::pending::<T>().await
}
/// Resolves to the provided value.
///
/// This function is an async version of [`std::convert::identity`].
///
/// [`std::convert::identity`]: https://doc.rust-lang.org/std/convert/fn.identity.html
///
/// # Examples
///
/// ```
/// # #![feature(async_await)]
/// use async_std::future::ready;
///
/// # async_std::task::block_on(async {
/// assert_eq!(ready(10).await, 10);
/// # })
/// ```
pub async fn ready<T>(val: T) -> T {
val
}