Jan :rust: :ferris: · @janriemer
395 followers · 532 posts · Server floss.social

@danielzenzes I never had a need for breaking out of nested loops.

On a related note: when you want to break out of a control flow, e.g. when traversing a tree structure with a visitor, you can also use

std::ops::ControlFlow

doc.rust-lang.org/std/ops/enum

It makes breaking out of control flow much more explicit.

And it can also be used with `?` operator in order to return early when it's value is ControlFlow::Break. :awesome:

#explicitoverimplicit #controlflow #rustlang #Rust

Last updated 2 years ago