Skip to content

Commit 5598d53

Browse files
authored
Rollup merge of #148248 - nxsaken:const_control_flow, r=Mark-Simulacrum
Constify `ControlFlow` methods without unstable bounds Feature: `min_const_control_flow` Tracking issue: #148738 This PR constifies some of the methods on `ControlFlow`.
2 parents 86b95eb + d05133f commit 5598d53

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

library/core/src/ops/control_flow.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ impl<B, C> ControlFlow<B, C> {
150150
/// ```
151151
#[inline]
152152
#[stable(feature = "control_flow_enum_is", since = "1.59.0")]
153-
pub fn is_break(&self) -> bool {
153+
#[rustc_const_unstable(feature = "min_const_control_flow", issue = "148738")]
154+
pub const fn is_break(&self) -> bool {
154155
matches!(*self, ControlFlow::Break(_))
155156
}
156157

@@ -166,7 +167,8 @@ impl<B, C> ControlFlow<B, C> {
166167
/// ```
167168
#[inline]
168169
#[stable(feature = "control_flow_enum_is", since = "1.59.0")]
169-
pub fn is_continue(&self) -> bool {
170+
#[rustc_const_unstable(feature = "min_const_control_flow", issue = "148738")]
171+
pub const fn is_continue(&self) -> bool {
170172
matches!(*self, ControlFlow::Continue(_))
171173
}
172174

@@ -257,7 +259,8 @@ impl<B, C> ControlFlow<B, C> {
257259
/// ```
258260
#[inline]
259261
#[unstable(feature = "control_flow_ok", issue = "140266")]
260-
pub fn break_ok(self) -> Result<B, C> {
262+
#[rustc_const_unstable(feature = "min_const_control_flow", issue = "148738")]
263+
pub const fn break_ok(self) -> Result<B, C> {
261264
match self {
262265
ControlFlow::Continue(c) => Err(c),
263266
ControlFlow::Break(b) => Ok(b),
@@ -361,7 +364,8 @@ impl<B, C> ControlFlow<B, C> {
361364
/// ```
362365
#[inline]
363366
#[unstable(feature = "control_flow_ok", issue = "140266")]
364-
pub fn continue_ok(self) -> Result<C, B> {
367+
#[rustc_const_unstable(feature = "min_const_control_flow", issue = "148738")]
368+
pub const fn continue_ok(self) -> Result<C, B> {
365369
match self {
366370
ControlFlow::Continue(c) => Ok(c),
367371
ControlFlow::Break(b) => Err(b),

0 commit comments

Comments
 (0)