As alternative to the proposed evaluating for to either () or Some(T) depending on the break t, as both types implement the Default trait:
- If there is a
break tin theforthen it should evaluate to the type of t. - If the
forcan end without abreak tstatement (is this always true?), then the type must implementDefault, whose default value is used. - If there are non-agreeing
breaks then it is a syntax error. - If there is no
breakelement we advise type inference to be(), but it could be anyDefault. E.g., with aforbeing assigned into a variable and then removing all itsbreakstatements.
This should be completely compatible with existent code. I have no idea if it would imply some notable change in the compiler. Does the compiler have a notion of the Default trait?