]> git.lizzy.rs Git - rust.git/blobdiff - library/core/src/future/ready.rs
Revert "Implement allow-by-default multiple_supertrait_upcastable lint"
[rust.git] / library / core / src / future / ready.rs
index 48f20f90a3253c202572fb6dc78e0bf897a98509..a07b63fb62b9023a70bca9c419d1890c4124aa86 100644 (file)
@@ -24,6 +24,30 @@ fn poll(mut self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<T> {
     }
 }
 
+impl<T> Ready<T> {
+    /// Consumes the `Ready`, returning the wrapped value.
+    ///
+    /// # Panics
+    ///
+    /// Will panic if this [`Ready`] was already polled to completion.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// #![feature(ready_into_inner)]
+    /// use std::future;
+    ///
+    /// let a = future::ready(1);
+    /// assert_eq!(a.into_inner(), 1);
+    /// ```
+    #[unstable(feature = "ready_into_inner", issue = "101196")]
+    #[must_use]
+    #[inline]
+    pub fn into_inner(self) -> T {
+        self.0.expect("Called `into_inner()` on `Ready` after completion")
+    }
+}
+
 /// Creates a future that is immediately ready with a value.
 ///
 /// Futures created through this function are functionally similar to those