Skip to content

Commit 69e0658

Browse files
authored
Rollup merge of rust-lang#78200 - LeSeulArtichaut:controlflow-is-meth, r=scottmcm
Add `ControlFlow::is_{break,continue}` methods r? @scottmcm cc rust-lang#75744
2 parents 6bfbc24 + d25c97a commit 69e0658

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

library/core/src/ops/control_flow.rs

+14
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@ impl<C, B> Try for ControlFlow<C, B> {
3232
}
3333

3434
impl<C, B> ControlFlow<C, B> {
35+
/// Returns `true` if this is a `Break` variant.
36+
#[inline]
37+
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
38+
pub fn is_break(&self) -> bool {
39+
matches!(*self, ControlFlow::Break(_))
40+
}
41+
42+
/// Returns `true` if this is a `Continue` variant.
43+
#[inline]
44+
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
45+
pub fn is_continue(&self) -> bool {
46+
matches!(*self, ControlFlow::Continue(_))
47+
}
48+
3549
/// Converts the `ControlFlow` into an `Option` which is `Some` if the
3650
/// `ControlFlow` was `Break` and `None` otherwise.
3751
#[inline]

0 commit comments

Comments
 (0)