You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The reason I'm opening this issue is that there has been some activity on the old issues, regarding returning values with break from for and while loops:
Rereading those threads, the main issues why those were originally closed seem to be:
else being a confusing name for this block
not being able to add a new keyword that makes the meaning of the block clear
there was no experience with the loop version of the break <value> syntax
Number 1 is still valid (although some disagree). 3 is not valid anymore, this feature was stabilized more than 4 years ago in 2017. Number 2 seems much less of a problem these days, since we now have editions (which we didn't have when these original issues were opened).
That's why I'm proposing to reserve nobreak as a keyword in Rust Edition 2021. That way we at can add this feature in the future, using a clear keyword.
I think nobreak clearly shows the meaning of the block. It's the block that you enter when there was no break. Code would then look like this:
let found_six = for val in[1,4,3,2]{if val == 6{breaktrue;}}nobreak{
false
}
The reason I'm opening this issue is that there has been some activity on the old issues, regarding returning values with
breakfromforandwhileloops:Rereading those threads, the main issues why those were originally closed seem to be:
elsebeing a confusing name for this blockloopversion of thebreak <value>syntaxNumber 1 is still valid (although some disagree). 3 is not valid anymore, this feature was stabilized more than 4 years ago in 2017. Number 2 seems much less of a problem these days, since we now have editions (which we didn't have when these original issues were opened).
That's why I'm proposing to reserve
nobreakas a keyword in Rust Edition 2021. That way we at can add this feature in the future, using a clear keyword.I think
nobreakclearly shows the meaning of the block. It's the block that you enter when there was no break. Code would then look like this: