Skip to content

Commit

Permalink
Rollup merge of rust-lang#89446 - chrismit3s:issue-88715-fix, r=josht…
Browse files Browse the repository at this point in the history
…riplett

Add paragraph to ControlFlow docs to menion it works with the ? operator (rust-lang#88715)

fixes rust-lang#88715

r? `@steveklabnik`
  • Loading branch information
matthiaskrgr committed Oct 31, 2021
2 parents 46ce6a7 + 825cd81 commit 2ce7c36
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions library/core/src/ops/control_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ use crate::{convert, ops};
/// Having the enum makes it clearer -- no more wondering "wait, what did `false`
/// mean again?" -- and allows including a value.
///
/// Similar to [`Option`] and [`Result`], this enum can be used with the `?` operator
/// to return immediately if the [`Break`] variant is present or otherwise continue normally
/// with the value inside the [`Continue`] variant.
///
/// # Examples
///
/// Early-exiting from [`Iterator::try_for_each`]:
Expand Down Expand Up @@ -71,6 +75,9 @@ use crate::{convert, ops};
/// assert_eq!(res, ControlFlow::Break(-1));
/// assert_eq!(sum, 6);
/// ```
///
/// [`Break`]: ControlFlow::Break
/// [`Continue`]: ControlFlow::Continue
#[stable(feature = "control_flow_enum_type", since = "1.55.0")]
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum ControlFlow<B, C = ()> {
Expand Down

0 comments on commit 2ce7c36

Please sign in to comment.