forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#72459 - yoshuawuyts:into-future, r=nikomats…
…akis Add core::future::IntoFuture This patch reintroduces the `core::future::IntoFuture` trait. However unlike earlier PRs this patch does not integrate it into the `async/.await` lowering since that lead to performance regressions. By introducing the trait separately from the integration, the integration PR can be more narrowly scoped, and people can start trying out the `IntoFuture` trait today. Thanks heaps! cc/ @rust-lang/wg-async-foundations ## References - Original PR adding `IntoFuture` rust-lang#65244 - Open issue to re-land `IntoFuture` (assigned to me) rust-lang#67982 - Tracking issue for `IntoFuture` rust-lang#67644
- Loading branch information
Showing
4 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use crate::future::Future; | ||
|
||
/// Conversion into a `Future`. | ||
#[unstable(feature = "into_future", issue = "67644")] | ||
pub trait IntoFuture { | ||
/// The output that the future will produce on completion. | ||
#[unstable(feature = "into_future", issue = "67644")] | ||
type Output; | ||
|
||
/// Which kind of future are we turning this into? | ||
#[unstable(feature = "into_future", issue = "67644")] | ||
type Future: Future<Output = Self::Output>; | ||
|
||
/// Creates a future from a value. | ||
#[unstable(feature = "into_future", issue = "67644")] | ||
fn into_future(self) -> Self::Future; | ||
} | ||
|
||
#[unstable(feature = "into_future", issue = "67644")] | ||
impl<F: Future> IntoFuture for F { | ||
type Output = F::Output; | ||
type Future = F; | ||
|
||
fn into_future(self) -> Self::Future { | ||
self | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters