Rollup merge of #78200 - LeSeulArtichaut:controlflow-is-meth, r=scottmcm

Add `ControlFlow::is_{break,continue}` methods

r? @scottmcm cc #75744
This commit is contained in:
Yuki Okushi 2020-10-22 09:45:45 +09:00 committed by GitHub
commit 69e0658f41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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]