> Break from labeled blocks is a pretty niche thing. I can remember a few cases it would have been useful, but I'm not sure I'll remember the feature exists next time it comes up.
Yeah, I feel like the vast majority of the time this would be better handled by splitting out that block into a function. There are situations where there the number of parameters needed to pass in would get unwieldy, but that is where I start thinking about if all that loose state is intrinsic to the problem, or a sign that I need to refactor my datastructures.
One reason to support this sort of feature is that it makes it easier to split changes into two reviewable steps: first make a minimal change that introduces some ugly thing like break-with-label, then clean it up with a no-change-of-behaviour commit.
Like with GAT, I think one of the major reasons to support this feature is because it feels consistent. "I can put generics here, but not there? I can break here but not there?". I've run into "accidentally" writing the equivalent of GAT before just because I had expected it to work.
The borrow checker is "smarter" within a single function body though, so factoring code into a separate function is not necessarily as easy as in other languages.
I ran into this issue years ago (possibly even before labeled exit from loops or even NLL, although I'd have to dig through some old code to confirm this). I had some logic that I wanted to short-circuit, but moving everything to a separate method call would have required an extra borrow that would not have been allowed. I don't think that I'll end up needing to use this feature much, but I'm glad to finally have it as an option for the rare cases when it will improve the readability of my code.
Yeah, I feel like the vast majority of the time this would be better handled by splitting out that block into a function. There are situations where there the number of parameters needed to pass in would get unwieldy, but that is where I start thinking about if all that loose state is intrinsic to the problem, or a sign that I need to refactor my datastructures.