I am implementing the iterators from Stepanov’s Elements of Programming in Rust, and they currently work like C++ iterators. Stepanov’s iterators and coordinates go much further into the classification of access patterns as an abstract algebra than Rust does, so you have:
and then you move on to multi-dimensional iterators and coordinate structures like:
- coordinates with mutable successors
You can see the elements_in_rust code here.
I need to resolve the naming issue above, as I would rather have as systematic way of doing it to avoid having to think of new names all the time. I think that value semantics should be the default, so:
fn half_nonnegative(mut self) -> Self
That leaves the other case:
fn replace_with_half_nonnegative(&mut self)
seems a bit long? maybe:
fn alter_half_nonnegative(&mut self)
I am not sure if I am going to leave the iterators like C++ iterators, or if they should be ranges like the Rust ones. I don’t think Rust iterators will work on trees and higher dimensional structures. So I have two choices, and I would be interested in opinions. I could rename the iterators ‘Cursors’ or ‘Coordinates’ and leave them “unsafe” as an alternative to the Rust built-in ones, or I could try and express the algorithms in terms of Rusts ‘Iterators’ (that are actually ranges).