rust-lang/rfcs — pull request #352 by P1start (2014-10-04 01:05:35+00:00)
Title: Allow loops to return values other than ()

Extend `for`, `loop`, and `while` loops to allow them to return values other than `()`:

- add an optional `else` clause that is evaluated if the loop ended without
using `break`;
- add an optional expression parameter to `break` expressions to break out of
a loop with a value.

[Rendered view](https://github.com/P1start/rfcs/blob/loop-else/active/0000-loops-returning-values.md)

(See also [this discuss thread](http://discuss.rust-lang.org/t/allow-loops-to-return-values-other-than/567).)