Personally as a proponent of the generator approach I don't care about value break
s that much. In practice I can't remember many cases of when I needed such feature. But I really hope that integration of generators into for
loops will help with the following pattern which is annoyingly common:
for value in iter {
let value = value?;
// ...
}
It even causes ad-hoc proposals like for val? in iter { .. }
instead f a more generic solution. Allowing value break
s is just a nice bonus.
Note that iteration over Iterator<Item=Result<T, E>>
has different semantics from iteration over Generator<Yield=T, Return=Result<(), E>>
. In the former case you may receive Ok
values after an error, but in the latter one the iteration must be terminated on a first error. (Unfortunately we do not enforce this constraint using type system, but it's a different discussion...)