about summary refs log tree commit diff
path: root/src/libcore/future/into_future.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/libcore/future/into_future.rs')
-rw-r--r--src/libcore/future/into_future.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/libcore/future/into_future.rs b/src/libcore/future/into_future.rs
new file mode 100644
index 00000000000..4020c254446
--- /dev/null
+++ b/src/libcore/future/into_future.rs
@@ -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
+    }
+}