Skip to content

Commit db82586

Browse files
committed
Use ops::ControlFlow in graph::iterate
1 parent 92f68fd commit db82586

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

core/src/iter/adapters/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1273,7 +1273,7 @@ where
12731273
) -> impl FnMut((), T) -> ControlFlow<(), B> + '_ {
12741274
move |(), x| match f(x) {
12751275
Some(x) => ControlFlow::Break(x),
1276-
None => ControlFlow::Continue(()),
1276+
None => ControlFlow::CONTINUE,
12771277
}
12781278
}
12791279

core/src/iter/traits/double_ended.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ pub trait DoubleEndedIterator: Iterator {
310310
mut predicate: impl FnMut(&T) -> bool,
311311
) -> impl FnMut((), T) -> ControlFlow<(), T> {
312312
move |(), x| {
313-
if predicate(&x) { ControlFlow::Break(x) } else { ControlFlow::Continue(()) }
313+
if predicate(&x) { ControlFlow::Break(x) } else { ControlFlow::CONTINUE }
314314
}
315315
}
316316

core/src/ops/control_flow.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,10 @@ impl<R: Try> ControlFlow<R::Ok, R> {
6565
}
6666
}
6767
}
68+
69+
impl<B> ControlFlow<(), B> {
70+
/// It's frequently the case that there's no value needed with `Continue`,
71+
/// so this provides a way to avoid typing `(())`, if you prefer it.
72+
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
73+
pub const CONTINUE: Self = ControlFlow::Continue(());
74+
}

0 commit comments

Comments
 (0)