diff --git a/library/core/src/ops/control_flow.rs b/library/core/src/ops/control_flow.rs index 776cea2ef791f..b0c15898a1fd8 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 {