Stabilize future readiness fns
This commit is contained in:
parent
ef1d58e7c9
commit
688f4471fd
6 changed files with 24 additions and 18 deletions
|
@ -21,9 +21,9 @@ pub use self::future::Future;
|
||||||
#[unstable(feature = "into_future", issue = "67644")]
|
#[unstable(feature = "into_future", issue = "67644")]
|
||||||
pub use into_future::IntoFuture;
|
pub use into_future::IntoFuture;
|
||||||
|
|
||||||
#[unstable(feature = "future_readiness_fns", issue = "70921")]
|
#[stable(feature = "future_readiness_fns", since = "1.47.0")]
|
||||||
pub use pending::{pending, Pending};
|
pub use pending::{pending, Pending};
|
||||||
#[unstable(feature = "future_readiness_fns", issue = "70921")]
|
#[stable(feature = "future_readiness_fns", since = "1.47.0")]
|
||||||
pub use ready::{ready, Ready};
|
pub use ready::{ready, Ready};
|
||||||
|
|
||||||
#[unstable(feature = "future_poll_fn", issue = "72302")]
|
#[unstable(feature = "future_poll_fn", issue = "72302")]
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use crate::fmt::{self, Debug};
|
||||||
use crate::future::Future;
|
use crate::future::Future;
|
||||||
use crate::marker;
|
use crate::marker;
|
||||||
use crate::pin::Pin;
|
use crate::pin::Pin;
|
||||||
|
@ -10,8 +11,7 @@ use crate::task::{Context, Poll};
|
||||||
/// documentation for more.
|
/// documentation for more.
|
||||||
///
|
///
|
||||||
/// [`pending`]: fn.pending.html
|
/// [`pending`]: fn.pending.html
|
||||||
#[unstable(feature = "future_readiness_fns", issue = "70921")]
|
#[stable(feature = "future_readiness_fns", since = "1.47.0")]
|
||||||
#[derive(Debug)]
|
|
||||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||||
pub struct Pending<T> {
|
pub struct Pending<T> {
|
||||||
_data: marker::PhantomData<T>,
|
_data: marker::PhantomData<T>,
|
||||||
|
@ -23,7 +23,6 @@ pub struct Pending<T> {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// #![feature(future_readiness_fns)]
|
|
||||||
/// use core::future;
|
/// use core::future;
|
||||||
///
|
///
|
||||||
/// # async fn run() {
|
/// # async fn run() {
|
||||||
|
@ -32,12 +31,12 @@ pub struct Pending<T> {
|
||||||
/// unreachable!();
|
/// unreachable!();
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
#[unstable(feature = "future_readiness_fns", issue = "70921")]
|
#[stable(feature = "future_readiness_fns", since = "1.47.0")]
|
||||||
pub fn pending<T>() -> Pending<T> {
|
pub fn pending<T>() -> Pending<T> {
|
||||||
Pending { _data: marker::PhantomData }
|
Pending { _data: marker::PhantomData }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "future_readiness_fns", issue = "70921")]
|
#[stable(feature = "future_readiness_fns", since = "1.47.0")]
|
||||||
impl<T> Future for Pending<T> {
|
impl<T> Future for Pending<T> {
|
||||||
type Output = T;
|
type Output = T;
|
||||||
|
|
||||||
|
@ -46,10 +45,17 @@ impl<T> Future for Pending<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "future_readiness_fns", issue = "70921")]
|
#[stable(feature = "future_readiness_fns", since = "1.47.0")]
|
||||||
impl<T> Unpin for Pending<T> {}
|
impl<T> Unpin for Pending<T> {}
|
||||||
|
|
||||||
#[unstable(feature = "future_readiness_fns", issue = "70921")]
|
#[stable(feature = "future_readiness_fns", since = "1.47.0")]
|
||||||
|
impl<T> Debug for Pending<T> {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
f.debug_struct("Pending").finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[stable(feature = "future_readiness_fns", since = "1.47.0")]
|
||||||
impl<T> Clone for Pending<T> {
|
impl<T> Clone for Pending<T> {
|
||||||
fn clone(&self) -> Self {
|
fn clone(&self) -> Self {
|
||||||
pending()
|
pending()
|
||||||
|
|
|
@ -8,15 +8,15 @@ use crate::task::{Context, Poll};
|
||||||
/// documentation for more.
|
/// documentation for more.
|
||||||
///
|
///
|
||||||
/// [`ready`]: fn.ready.html
|
/// [`ready`]: fn.ready.html
|
||||||
#[unstable(feature = "future_readiness_fns", issue = "70921")]
|
#[stable(feature = "future_readiness_fns", since = "1.47.0")]
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||||
pub struct Ready<T>(Option<T>);
|
pub struct Ready<T>(Option<T>);
|
||||||
|
|
||||||
#[unstable(feature = "future_readiness_fns", issue = "70921")]
|
#[stable(feature = "future_readiness_fns", since = "1.47.0")]
|
||||||
impl<T> Unpin for Ready<T> {}
|
impl<T> Unpin for Ready<T> {}
|
||||||
|
|
||||||
#[unstable(feature = "future_readiness_fns", issue = "70921")]
|
#[stable(feature = "future_readiness_fns", since = "1.47.0")]
|
||||||
impl<T> Future for Ready<T> {
|
impl<T> Future for Ready<T> {
|
||||||
type Output = T;
|
type Output = T;
|
||||||
|
|
||||||
|
@ -28,10 +28,13 @@ impl<T> Future for Ready<T> {
|
||||||
|
|
||||||
/// Creates a future that is immediately ready with a value.
|
/// Creates a future that is immediately ready with a value.
|
||||||
///
|
///
|
||||||
|
/// Futures created through this function are functionally similar to those
|
||||||
|
/// created through `async {}`. The main difference is that futures created
|
||||||
|
/// through this function are named and implement `Unpin`.
|
||||||
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(future_readiness_fns)]
|
|
||||||
/// use core::future;
|
/// use core::future;
|
||||||
///
|
///
|
||||||
/// # async fn run() {
|
/// # async fn run() {
|
||||||
|
@ -39,7 +42,7 @@ impl<T> Future for Ready<T> {
|
||||||
/// assert_eq!(a.await, 1);
|
/// assert_eq!(a.await, 1);
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
#[unstable(feature = "future_readiness_fns", issue = "70921")]
|
#[stable(feature = "future_readiness_fns", since = "1.47.0")]
|
||||||
pub fn ready<T>(t: T) -> Ready<T> {
|
pub fn ready<T>(t: T) -> Ready<T> {
|
||||||
Ready(Some(t))
|
Ready(Some(t))
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(future_readiness_fns)]
|
|
||||||
/// #![feature(ready_macro)]
|
/// #![feature(ready_macro)]
|
||||||
///
|
///
|
||||||
/// use core::task::{ready, Context, Poll};
|
/// use core::task::{ready, Context, Poll};
|
||||||
|
@ -27,7 +26,6 @@
|
||||||
/// The `ready!` call expands to:
|
/// The `ready!` call expands to:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # #![feature(future_readiness_fns)]
|
|
||||||
/// # #![feature(ready_macro)]
|
/// # #![feature(ready_macro)]
|
||||||
/// #
|
/// #
|
||||||
/// # use core::task::{Context, Poll};
|
/// # use core::task::{Context, Poll};
|
||||||
|
|
|
@ -9,7 +9,7 @@ pub use core::future::Future;
|
||||||
pub use core::future::{from_generator, get_context, ResumeTy};
|
pub use core::future::{from_generator, get_context, ResumeTy};
|
||||||
|
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
#[unstable(feature = "future_readiness_fns", issue = "70921")]
|
#[stable(feature = "future_readiness_fns", since = "1.47.0")]
|
||||||
pub use core::future::{pending, ready, Pending, Ready};
|
pub use core::future::{pending, ready, Pending, Ready};
|
||||||
|
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
|
|
|
@ -268,7 +268,6 @@
|
||||||
#![feature(external_doc)]
|
#![feature(external_doc)]
|
||||||
#![feature(fn_traits)]
|
#![feature(fn_traits)]
|
||||||
#![feature(format_args_nl)]
|
#![feature(format_args_nl)]
|
||||||
#![feature(future_readiness_fns)]
|
|
||||||
#![feature(gen_future)]
|
#![feature(gen_future)]
|
||||||
#![feature(generator_trait)]
|
#![feature(generator_trait)]
|
||||||
#![feature(global_asm)]
|
#![feature(global_asm)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue