Le 11/08/2013 23:18, Jens Nockert a écrit :
for i in iterations {
…
if converged {
break;
}
}
if iterations.finished() {
fail!("Oh noes, it did not converge");
}
The only way to implement .finished() non destructively (so that, when
returning false, it does not eat an element) is with a Peekable iterator
as in this pull request:
https://github.com/mozilla/rust/pull/8428
Then .finished() is .peek().is_none().
But this is unnecessary overhead if you don’t otherwise use .peek(). The
for-loop already knows how it exited.
--
Simon Sapin
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev