diff options
| author | bors <bors@rust-lang.org> | 2019-12-28 00:18:59 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-12-28 00:18:59 +0000 |
| commit | 3a087ad3a924be12343bb035bf9b63ed81f650bf (patch) | |
| tree | 280371e5569301f96fa6ed0a2498625a90795e28 /src/libcore/future/future.rs | |
| parent | 74c4e6a981d3150db8444c8d250e50bbe6b93b6b (diff) | |
| parent | 65bbcf0e13d0ce81f443b2fcfc5548b589c8462e (diff) | |
Auto merge of #67670 - oli-obk:rollup-2dp08sd, r=oli-obk
Rollup of 15 pull requests Successful merges: - #65244 (add IntoFuture trait and support for await) - #67576 (reuse `capacity` variable in slice::repeat) - #67588 (Use NonNull in slice::Iter and slice::IterMut.) - #67594 (Update libc to 0.2.66) - #67602 (Use issue = "none" instead of "0" in intrinsics) - #67604 (Add Scalar::to_(u|i)16 methods) - #67617 (Remove `compiler_builtins_lib` documentation) - #67621 (Use the correct type for static qualifs) - #67629 (Remove redundant link texts) - #67632 (Convert collapsed to shortcut reference links) - #67633 (Update .mailmap) - #67635 (Document safety of Path casting) - #67654 (Add regression test for old NLL ICE) - #67659 (Stabilize the `matches!` macro) - #67664 (Fix some mailmap entries) Failed merges: r? @ghost
Diffstat (limited to 'src/libcore/future/future.rs')
| -rw-r--r-- | src/libcore/future/future.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/libcore/future/future.rs b/src/libcore/future/future.rs index f14ed38b9b0..dcb819f9381 100644 --- a/src/libcore/future/future.rs +++ b/src/libcore/future/future.rs @@ -99,6 +99,21 @@ pub trait Future { fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>; } +/// 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; +} + #[stable(feature = "futures_api", since = "1.36.0")] impl<F: ?Sized + Future + Unpin> Future for &mut F { type Output = F::Output; @@ -119,3 +134,13 @@ where Pin::get_mut(self).as_mut().poll(cx) } } + +#[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 + } +} |
