Skip to content

Commit

Permalink
Make ControlFlow #[must_use]
Browse files Browse the repository at this point in the history
  • Loading branch information
LeSeulArtichaut committed Oct 21, 2020
1 parent 22e6b9c commit 28a77c4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion library/core/src/ops/control_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<C, B> {
/// Continue in the loop, using the given value for the next iteration
Continue(C),
Expand Down Expand Up @@ -99,7 +100,7 @@ impl<C> ControlFlow<C, ()> {
/// 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 }
/// });
Expand Down

0 comments on commit 28a77c4

Please sign in to comment.