diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2021-10-31 09:20:21 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-31 09:20:21 +0100 |
| commit | e7be8a2c074cb2e198160f599a0ed2745665561a (patch) | |
| tree | 4070b2da74524ddbf2a40a5b8838c4c2038c42f2 | |
| parent | 0a09858b05bb0d92e87077c76fcb0648d32d44db (diff) | |
| parent | 825cd8101835cc7af2036c1a8a5f9febb72f42aa (diff) | |
| download | rust-e7be8a2c074cb2e198160f599a0ed2745665561a.tar.gz rust-e7be8a2c074cb2e198160f599a0ed2745665561a.zip | |
Rollup merge of #89446 - chrismit3s:issue-88715-fix, r=joshtriplett
Add paragraph to ControlFlow docs to menion it works with the ? operator (#88715) fixes #88715 r? ```@steveklabnik```
| -rw-r--r-- | library/core/src/ops/control_flow.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/library/core/src/ops/control_flow.rs b/library/core/src/ops/control_flow.rs index 776cea2ef79..b0c15898a1f 100644 --- a/library/core/src/ops/control_flow.rs +++ b/library/core/src/ops/control_flow.rs @@ -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`]: @@ -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 = ()> { |
