Skip to content

Commit 28a77c4

Browse files
Make ControlFlow #[must_use]
1 parent 22e6b9c commit 28a77c4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

library/core/src/ops/control_flow.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::ops::Try;
33
/// Used to make try_fold closures more like normal loops
44
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
55
#[derive(Debug, Clone, Copy, PartialEq)]
6+
#[must_use = "this `ControlFlow` may be a `Break` variant, which should be handled"]
67
pub enum ControlFlow<C, B> {
78
/// Continue in the loop, using the given value for the next iteration
89
Continue(C),
@@ -99,7 +100,7 @@ impl<C> ControlFlow<C, ()> {
99100
/// use std::ops::ControlFlow;
100101
///
101102
/// let mut partial_sum = 0;
102-
/// (1..10).chain(20..25).try_for_each(|x| {
103+
/// let _ = (1..10).chain(20..25).try_for_each(|x| {
103104
/// if partial_sum > 100 { ControlFlow::BREAK }
104105
/// else { partial_sum += x; ControlFlow::CONTINUE }
105106
/// });

0 commit comments

Comments
 (0)