On 10.08.2013 16:10, Simon Sapin wrote:
> Proposal:
>
> for i in iter {
> // ...
> } else {
> // ...
> }
>
> The optional else block is executed when the for loop stops without
> exhausting the iterator, ie. when "break" is used.
Maybe that's common to python devs, but I would expect else to be
executed if the iterator yielded nothing/was empty.
IMO if you break you'll already be in a conditional of some sort in the
for body, so you can add more code there. But the else-on-empty would
save you the trouble of wrapping the whole for block e.g.:
if not empty { for { ... } } else { ... }
Cheers
--
Jordi Boggiano
@seldaek - http://nelm.io/jordi
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev