4 ms·
Well, in 0.7 the external iterator `each` pattern is mostly gone, leaving external iterators the standard style, but because the semantics of `for` haven't chan
by chrismorgan 13y ago
Well, in 0.7 the external iterator `each` pattern is mostly gone, leaving external iterators the standard style, but because the semantics of `for` haven't changed yet, there is an `advance` method provided for iterators, such that the code is actually at present thus:
for [1, 2, 3].iter().advance |i| { /* a closure */ }
- kibwen 13y agoRight, I was hoping we could avoid mentioning this brief and ugly interlude in our evolution. :)
- bjz_ 13y agoIt's been a courageous effort by strcat, pushing such ugliness on us over the 0.7 milestone, but it will certainly pay off into the future. I look forward to the new sugar!
- anonymous 13y agoThat is basically a while loop without a "proper body", right? At each iteration advance is called with the closure as first argument and iteration continues until it returns false?
- kibwen 13y agoYou're correct. You can see as much here in the implementation of `advance` (as you'd expect, it's very simple): https://github.com/mozilla/rust/blob/master/src/libstd/iterator.rs#L472 https://github.com/mozilla/rust/blob/master/src/libstd/itera...