pre-RFC: Allow return, continue, and break to affect the captured environment

Something like this came up in passing in this thread from last summer. To avoid breakage, it was suggested to annotate the closure to indicate that it might have control-flow effects on the outer scope:

let connection = get_connection().or_else(do |err|
    return Outcome::Failure((Status::InternalServerError, err)));

I don’t have a strong opinion on the idea in general: yeah, if we had that I would probably find uses for it, but so far (which isn’t very far) I don’t feel I need it.

2 Likes