diff options
| author | LeSeulArtichaut <leseulartichaut@gmail.com> | 2020-10-21 21:50:08 +0200 |
|---|---|---|
| committer | LeSeulArtichaut <leseulartichaut@gmail.com> | 2020-10-21 21:50:08 +0200 |
| commit | d25c97a3f88979490faa0ae07fa4dd1ba26eb5ff (patch) | |
| tree | cae20388c4e1c03d041ec9c7c116ed0fd223419c | |
| parent | 22e6b9c68941996daa45786b4145e6196e51f0f4 (diff) | |
| download | rust-d25c97a3f88979490faa0ae07fa4dd1ba26eb5ff.tar.gz rust-d25c97a3f88979490faa0ae07fa4dd1ba26eb5ff.zip | |
Add `ControlFlow::is_{break,continue}` methods
| -rw-r--r-- | library/core/src/ops/control_flow.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/library/core/src/ops/control_flow.rs b/library/core/src/ops/control_flow.rs index b0c7dc1a518..3bca3ff9733 100644 --- a/library/core/src/ops/control_flow.rs +++ b/library/core/src/ops/control_flow.rs @@ -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] |
