On Fri, Jun 7, 2013 at 12:58 AM, Sebastian Sylvan <sebastian.syl...@gmail.com> wrote: > The linked article contrasts them with the GoF-style iterators as well. > > The Rust Iterator trait is similar to the "one pass ranges" (and possibly > forward ranges), but not double-ended ranges or random-access ranges. It's > the *family* of range-based iterators that makes it flexible (e.g. allowing > you to write an efficient in-place reverse without knowing the underlying > data structure, using a double-ended range). > > See fig. 3: > http://www.informit.com/content/images/art_alexandrescu3_iterators/elementLinks/alexandrescu3_fig03.jpg
The extent to which you can have mutable iterators in Rust is pretty small, because of the memory safety requirement. Iterators can't open up a hole allowing multiple mutable references to the same object to be obtained, so I don't think mutable bidirectional or random access iterators are possible. Forward iterators can't ever give you an alias because they're a single pass over the container. It's an easy guarantee to provide. _______________________________________________ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev