We should define a new trait Iterable like this:
pub trait Iterable<T> { fn iter() -> Iterator<T>; }
to organize libraries in a better way.
I’m not sure if we should also define another trait for iter_mut() (IterableMut or MutIterable ?)
In fact I believe
for r in obj { f(r); }
should desugar into
let mut it = obj.iter(); // add .iter()
loop match it.next() {
Some(r) => { f(r); }
None => { }
}
rather than
let mut it = obj;
loop match it.next() {
Some(r) => { f(r); }
None => { }
}
which is how it’s done now, but that’s another topic I’d like to discuss elsewhere.