std-method

ControlFlow::break_value — inspect stop payload

Consume the ControlFlow value and return the break payload as Some, or None for Continue. Use is_break if the payload must remain available. Stable since 1.83.0. Expected stdout (not executed): true Some("limit") Common mistake: Expecting the continuation payload or borrowing rather than consuming the enum.

Formal Syntax & Structure

rust syntaxrust
fn break_value(self) -> Option<B>

Working Example

Example Snippetrust
fn main() {    use std::ops::ControlFlow;    let stop: ControlFlow<&str, u32> = ControlFlow::Break("limit");    println!("{}", stop.is_break());    println!("{:?}", stop.break_value());}
Rust Reference