Skip to content

Commit 2ce7c36

Browse files
authored
Rollup merge of rust-lang#89446 - chrismit3s:issue-88715-fix, r=joshtriplett
Add paragraph to ControlFlow docs to menion it works with the ? operator (rust-lang#88715) fixes rust-lang#88715 r? `@steveklabnik`
2 parents 46ce6a7 + 825cd81 commit 2ce7c36

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

library/core/src/ops/control_flow.rs

+7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ use crate::{convert, ops};
77
/// Having the enum makes it clearer -- no more wondering "wait, what did `false`
88
/// mean again?" -- and allows including a value.
99
///
10+
/// Similar to [`Option`] and [`Result`], this enum can be used with the `?` operator
11+
/// to return immediately if the [`Break`] variant is present or otherwise continue normally
12+
/// with the value inside the [`Continue`] variant.
13+
///
1014
/// # Examples
1115
///
1216
/// Early-exiting from [`Iterator::try_for_each`]:
@@ -71,6 +75,9 @@ use crate::{convert, ops};
7175
/// assert_eq!(res, ControlFlow::Break(-1));
7276
/// assert_eq!(sum, 6);
7377
/// ```
78+
///
79+
/// [`Break`]: ControlFlow::Break
80+
/// [`Continue`]: ControlFlow::Continue
7481
#[stable(feature = "control_flow_enum_type", since = "1.55.0")]
7582
#[derive(Debug, Clone, Copy, PartialEq)]
7683
pub enum ControlFlow<B, C = ()> {

0 commit comments

Comments
 (0)