未验证 提交 9c6bcb60 编写于 作者: M Matthias Krüger 提交者: GitHub

Rollup merge of #98718 - yoshuawuyts:stabilize-into-future, r=yaahc

Stabilize `into_future`

https://github.com/rust-lang/rust/issues/67644 has been labeled with [S-tracking-ready-to-stabilize](https://github.com/rust-lang/rust/labels/S-tracking-ready-to-stabilize) - which mentions someone needs to file a stabilization PR. So hence this PR!  Thanks!

Closes https://github.com/rust-lang/rust/issues/67644

r? ``@joshtriplett``
...@@ -13,8 +13,6 @@ ...@@ -13,8 +13,6 @@
/// on all futures. /// on all futures.
/// ///
/// ```no_run /// ```no_run
/// #![feature(into_future)]
///
/// use std::future::IntoFuture; /// use std::future::IntoFuture;
/// ///
/// # async fn foo() { /// # async fn foo() {
...@@ -33,8 +31,6 @@ ...@@ -33,8 +31,6 @@
/// multiple times before being `.await`ed. /// multiple times before being `.await`ed.
/// ///
/// ```rust /// ```rust
/// #![feature(into_future)]
///
/// use std::future::{ready, Ready, IntoFuture}; /// use std::future::{ready, Ready, IntoFuture};
/// ///
/// /// Eventually multiply two numbers /// /// Eventually multiply two numbers
...@@ -91,8 +87,6 @@ ...@@ -91,8 +87,6 @@
/// `IntoFuture::into_future` to obtain an instance of `Future`: /// `IntoFuture::into_future` to obtain an instance of `Future`:
/// ///
/// ```rust /// ```rust
/// #![feature(into_future)]
///
/// use std::future::IntoFuture; /// use std::future::IntoFuture;
/// ///
/// /// Convert the output of a future to a string. /// /// Convert the output of a future to a string.
...@@ -104,14 +98,14 @@ ...@@ -104,14 +98,14 @@
/// format!("{:?}", fut.await) /// format!("{:?}", fut.await)
/// } /// }
/// ``` /// ```
#[unstable(feature = "into_future", issue = "67644")] #[stable(feature = "into_future", since = "1.64.0")]
pub trait IntoFuture { pub trait IntoFuture {
/// The output that the future will produce on completion. /// The output that the future will produce on completion.
#[unstable(feature = "into_future", issue = "67644")] #[stable(feature = "into_future", since = "1.64.0")]
type Output; type Output;
/// Which kind of future are we turning this into? /// Which kind of future are we turning this into?
#[unstable(feature = "into_future", issue = "67644")] #[stable(feature = "into_future", since = "1.64.0")]
type IntoFuture: Future<Output = Self::Output>; type IntoFuture: Future<Output = Self::Output>;
/// Creates a future from a value. /// Creates a future from a value.
...@@ -121,8 +115,6 @@ pub trait IntoFuture { ...@@ -121,8 +115,6 @@ pub trait IntoFuture {
/// Basic usage: /// Basic usage:
/// ///
/// ```no_run /// ```no_run
/// #![feature(into_future)]
///
/// use std::future::IntoFuture; /// use std::future::IntoFuture;
/// ///
/// # async fn foo() { /// # async fn foo() {
...@@ -131,12 +123,12 @@ pub trait IntoFuture { ...@@ -131,12 +123,12 @@ pub trait IntoFuture {
/// assert_eq!("meow", fut.await); /// assert_eq!("meow", fut.await);
/// # } /// # }
/// ``` /// ```
#[unstable(feature = "into_future", issue = "67644")] #[stable(feature = "into_future", since = "1.64.0")]
#[lang = "into_future"] #[lang = "into_future"]
fn into_future(self) -> Self::IntoFuture; fn into_future(self) -> Self::IntoFuture;
} }
#[unstable(feature = "into_future", issue = "67644")] #[stable(feature = "into_future", since = "1.64.0")]
impl<F: Future> IntoFuture for F { impl<F: Future> IntoFuture for F {
type Output = F::Output; type Output = F::Output;
type IntoFuture = F; type IntoFuture = F;
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#[unstable(feature = "future_join", issue = "91642")] #[unstable(feature = "future_join", issue = "91642")]
pub use self::join::join; pub use self::join::join;
#[unstable(feature = "into_future", issue = "67644")] #[stable(feature = "into_future", since = "1.64.0")]
pub use into_future::IntoFuture; pub use into_future::IntoFuture;
#[stable(feature = "future_readiness_fns", since = "1.48.0")] #[stable(feature = "future_readiness_fns", since = "1.48.0")]
......
// run-pass // run-pass
// aux-build: issue-72470-lib.rs // aux-build: issue-72470-lib.rs
// edition:2021 // edition:2021
#![feature(into_future)]
extern crate issue_72470_lib; extern crate issue_72470_lib;
use std::{future::{Future, IntoFuture}, pin::Pin}; use std::{future::{Future, IntoFuture}, pin::Pin};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册