On 2/29/12 5:11 PM, Niko Matsakis wrote:
Presuming (of course) that the iterator respects "break", and that the
iterator didn't intend to perform any action after the iteration
terminated, I think it's TCP-preserving. These seem like reasonable
assumptions to me.
I was thinking about this more. It's not entirely clear to me what
TCP-preserving means in this context. The best I could come up with is
this.
If you had a while loop written like:
<init>
while <cond> {
<body(i)>
<next>
}
and you refactored this into an iterator:
fn iterator<T>(f: fn(T) -> bool) {
<init>
while <cond> {
if (!f()) ret;
<next>
}
}
then doing:
for i in iterator() { <body(i)> }
would be the same.
I believe this holds.
Niko
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev