3 ms·
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 language
by edflsafoiewq 4y ago
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.
- Ar-Curunir 4y agoYou can use it with a closure to get the best of both worlds
- saghm 4y agoI 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.