std-type
ControlFlow — explicit early exit
Represent a deliberate stop independently of error handling. B is the break payload; C is the continuation payload. With try_for_each, C must be unit. Expected stdout (not executed): Break(20) Common mistake: Calling every Break an error or confusing it with the loop keyword.
Formal Syntax & Structure
rust syntaxrust
pub enum ControlFlow<B, C = ()> { Continue(C), Break(B) }Working Example
Example Snippetrust
fn main() { use std::ops::ControlFlow; let flow = [4, 8, 20].into_iter().try_for_each(|n| { if n > 10 { ControlFlow::Break(n) } else { ControlFlow::Continue(()) } }); println!("{flow:?}");}