diff options
| author | Mara Bos <m-ou.se@m-ou.se> | 2020-11-08 13:35:58 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-08 13:35:58 +0100 |
| commit | bdeace9f4edd2f8c1f06d147940a07550f133f42 (patch) | |
| tree | c44f8dff555b2fbff3d34131312685bcb74a1b6f /library/core/src/task | |
| parent | 1f034f77bc7cd5814cb341a1028f8955dc4262a5 (diff) | |
| parent | 5e80c65102f85700e1a449847dfa603e589df950 (diff) | |
Rollup merge of #76227 - CDirkx:const-poll, r=KodrAus
Stabilize `Poll::is_ready` and `is_pending` as const Insta-stabilize the methods `is_ready` and `is_pending` of `std::task::Poll` as const, in the same way as [PR#76198](https://github.com/rust-lang/rust/pull/76198). Possible because of the recent stabilization of const control flow. Part of #76225.
Diffstat (limited to 'library/core/src/task')
| -rw-r--r-- | library/core/src/task/poll.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/library/core/src/task/poll.rs b/library/core/src/task/poll.rs index 4e987a53b2c..6851f3fcd2f 100644 --- a/library/core/src/task/poll.rs +++ b/library/core/src/task/poll.rs @@ -39,15 +39,17 @@ impl<T> Poll<T> { /// Returns `true` if this is `Poll::Ready` #[inline] + #[rustc_const_stable(feature = "const_poll", since = "1.49.0")] #[stable(feature = "futures_api", since = "1.36.0")] - pub fn is_ready(&self) -> bool { + pub const fn is_ready(&self) -> bool { matches!(*self, Poll::Ready(_)) } /// Returns `true` if this is `Poll::Pending` #[inline] + #[rustc_const_stable(feature = "const_poll", since = "1.49.0")] #[stable(feature = "futures_api", since = "1.36.0")] - pub fn is_pending(&self) -> bool { + pub const fn is_pending(&self) -> bool { !self.is_ready() } } |
