about summary refs log tree commit diff
path: root/src/libcore/future/future.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/libcore/future/future.rs')
-rw-r--r--src/libcore/future/future.rs25
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
+    }
+}