From 28a77c4de1e5992f3004bbd4a5074b92a1a3ca8a Mon Sep 17 00:00:00 2001 From: LeSeulArtichaut Date: Wed, 21 Oct 2020 21:56:25 +0200 Subject: [PATCH] Make `ControlFlow` `#[must_use]` --- library/core/src/ops/control_flow.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/core/src/ops/control_flow.rs b/library/core/src/ops/control_flow.rs index b0c7dc1a5187..798e3f670624 100644 --- a/library/core/src/ops/control_flow.rs +++ b/library/core/src/ops/control_flow.rs @@ -3,6 +3,7 @@ use crate::ops::Try; /// Used to make try_fold closures more like normal loops #[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")] #[derive(Debug, Clone, Copy, PartialEq)] +#[must_use = "this `ControlFlow` may be a `Break` variant, which should be handled"] pub enum ControlFlow { /// Continue in the loop, using the given value for the next iteration Continue(C), @@ -99,7 +100,7 @@ impl ControlFlow { /// use std::ops::ControlFlow; /// /// let mut partial_sum = 0; - /// (1..10).chain(20..25).try_for_each(|x| { + /// let _ = (1..10).chain(20..25).try_for_each(|x| { /// if partial_sum > 100 { ControlFlow::BREAK } /// else { partial_sum += x; ControlFlow::CONTINUE } /// });