Okay, so this is obviously pretty wild and one may argue that it reduces clarity but I propose deprecating continue, return and break and replacing them with the far more general escape combined with labeled scopes.
Like labelled loops introducing labeled scopes as a generalization:
'label:{ /* ... */ }
fn factorial ( n : u32 ) -> u32 'label:{
/* ... */
}
if 1 > 2 'label:{ /* ... */ }
As you might imagine escape 'label:$expr escapes to the nearest enclosing label that matches it like in loops and also returns the value which becomes the return value of the scope.
This can obviously be used to implement return but also continue and break:
for i in [0,1,2] 'continue:{
/* ... */
escape 'continue:();
/* ... */
};
'break:{ for i in [0,1,2] {
/* ... */
escape 'break:();
/* ... */
}};
Also implementing returning values from loops.
Indeed Rust could just treat an unlabeled function outer scope as if it assigned the label 'return, similarly assigning 'continue and 'break labels by default for loops and treating return $expr as syntactic sugar for escape 'return:$expr andsoforth.
Since introducing a new keyword is obviously painful and since the return $expr syntax does not conflict with return 'label:$expr the return keyword can instead be used for escape. This would however require that return $expr does not return out of its nearest enclosing scope but defaults back to return 'return:#expr with the master scope of any function automatically named so.