Skip to content

Commit

Permalink
Rollup merge of #78200 - LeSeulArtichaut:controlflow-is-meth, r=scottmcm
Browse files Browse the repository at this point in the history
Add `ControlFlow::is_{break,continue}` methods

r? @scottmcm cc #75744
  • Loading branch information
JohnTitor committed Oct 22, 2020
2 parents 6bfbc24 + d25c97a commit 69e0658
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions library/core/src/ops/control_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@ impl<C, B> Try for ControlFlow<C, B> {
}

impl<C, B> ControlFlow<C, B> {
/// Returns `true` if this is a `Break` variant.
#[inline]
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
pub fn is_break(&self) -> bool {
matches!(*self, ControlFlow::Break(_))
}

/// Returns `true` if this is a `Continue` variant.
#[inline]
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
pub fn is_continue(&self) -> bool {
matches!(*self, ControlFlow::Continue(_))
}

/// Converts the `ControlFlow` into an `Option` which is `Some` if the
/// `ControlFlow` was `Break` and `None` otherwise.
#[inline]
Expand Down

0 comments on commit 69e0658

Please sign in to comment.