]> git.lizzy.rs Git - rust.git/blobdiff - src/libcore/task/poll.rs
Stabilize futures_api
[rust.git] / src / libcore / task / poll.rs
index ecf03afb88e2acbb1f35bda97ad29f2296b58c25..3db70d5e7645f1eccb4e288aa71c67c562768357 100644 (file)
@@ -1,6 +1,4 @@
-#![unstable(feature = "futures_api",
-            reason = "futures in libcore are unstable",
-            issue = "50547")]
+#![stable(feature = "futures_api", since = "1.36.0")]
 
 use crate::ops::Try;
 use crate::result::Result;
@@ -9,20 +7,27 @@
 /// scheduled to receive a wakeup instead.
 #[must_use = "this `Poll` may be a `Pending` variant, which should be handled"]
 #[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
+#[stable(feature = "futures_api", since = "1.36.0")]
 pub enum Poll<T> {
     /// Represents that a value is immediately ready.
-    Ready(T),
+    #[stable(feature = "futures_api", since = "1.36.0")]
+    Ready(
+        #[stable(feature = "futures_api", since = "1.36.0")]
+        T
+    ),
 
     /// Represents that a value is not ready yet.
     ///
     /// When a function returns `Pending`, the function *must* also
     /// ensure that the current task is scheduled to be awoken when
     /// progress can be made.
+    #[stable(feature = "futures_api", since = "1.36.0")]
     Pending,
 }
 
 impl<T> Poll<T> {
     /// Changes the ready value of this `Poll` with the closure provided.
+    #[stable(feature = "futures_api", since = "1.36.0")]
     pub fn map<U, F>(self, f: F) -> Poll<U>
         where F: FnOnce(T) -> U
     {
@@ -34,6 +39,7 @@ pub fn map<U, F>(self, f: F) -> Poll<U>
 
     /// Returns `true` if this is `Poll::Ready`
     #[inline]
+    #[stable(feature = "futures_api", since = "1.36.0")]
     pub fn is_ready(&self) -> bool {
         match *self {
             Poll::Ready(_) => true,
@@ -43,6 +49,7 @@ pub fn is_ready(&self) -> bool {
 
     /// Returns `true` if this is `Poll::Pending`
     #[inline]
+    #[stable(feature = "futures_api", since = "1.36.0")]
     pub fn is_pending(&self) -> bool {
         !self.is_ready()
     }
@@ -50,6 +57,7 @@ pub fn is_pending(&self) -> bool {
 
 impl<T, E> Poll<Result<T, E>> {
     /// Changes the success value of this `Poll` with the closure provided.
+    #[stable(feature = "futures_api", since = "1.36.0")]
     pub fn map_ok<U, F>(self, f: F) -> Poll<Result<U, E>>
         where F: FnOnce(T) -> U
     {
@@ -61,6 +69,7 @@ pub fn map_ok<U, F>(self, f: F) -> Poll<Result<U, E>>
     }
 
     /// Changes the error value of this `Poll` with the closure provided.
+    #[stable(feature = "futures_api", since = "1.36.0")]
     pub fn map_err<U, F>(self, f: F) -> Poll<Result<T, U>>
         where F: FnOnce(E) -> U
     {
@@ -72,12 +81,14 @@ pub fn map_err<U, F>(self, f: F) -> Poll<Result<T, U>>
     }
 }
 
+#[stable(feature = "futures_api", since = "1.36.0")]
 impl<T> From<T> for Poll<T> {
     fn from(t: T) -> Poll<T> {
         Poll::Ready(t)
     }
 }
 
+#[stable(feature = "futures_api", since = "1.36.0")]
 impl<T, E> Try for Poll<Result<T, E>> {
     type Ok = Poll<T>;
     type Error = E;
@@ -102,6 +113,7 @@ fn from_ok(x: Self::Ok) -> Self {
     }
 }
 
+#[stable(feature = "futures_api", since = "1.36.0")]
 impl<T, E> Try for Poll<Option<Result<T, E>>> {
     type Ok = Poll<Option<T>>;
     type Error = E;