Skip to content

Commit 407add0

Browse files
committed
Stabilize Poll::is_ready and is_pending as const
Insta-stabilize the methods `is_ready` and `is_pending` of `Poll`. Possible because of the recent stabilization of const control flow. Also adds a test for these methods in a const context.
1 parent 5ec9fda commit 407add0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

core/src/task/poll.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,17 @@ impl<T> Poll<T> {
3939

4040
/// Returns `true` if this is `Poll::Ready`
4141
#[inline]
42+
#[rustc_const_stable(feature = "const_poll", since = "1.48.0")]
4243
#[stable(feature = "futures_api", since = "1.36.0")]
43-
pub fn is_ready(&self) -> bool {
44+
pub const fn is_ready(&self) -> bool {
4445
matches!(*self, Poll::Ready(_))
4546
}
4647

4748
/// Returns `true` if this is `Poll::Pending`
4849
#[inline]
50+
#[rustc_const_stable(feature = "const_poll", since = "1.48.0")]
4951
#[stable(feature = "futures_api", since = "1.36.0")]
50-
pub fn is_pending(&self) -> bool {
52+
pub const fn is_pending(&self) -> bool {
5153
!self.is_ready()
5254
}
5355
}

0 commit comments

Comments
 (0)