by pcwalton · 10y ago · 0 comments
I agree that a summary would be good, but this doesn't require a PL Ph.D. It means "cycle is a method that moves its receiver and returns a Cycle object of the same type of the receiver, and only works if the receiver is cloneable". The trickiest thing here, IMHO, is move semantics, which is something fundamental to Rust in general.
If you've spent more than a cursory time with Rust this is pretty straightforward.
You'd represent this in Java(minus move semantics, because Java has nothing like that) via:
class IntoIter {
public Cycle<T extends Clone> { ... }
...
}
Where Clone is just an interface that knows how to clone its value.I think the point still holds. Maybe just not for that one.
I guess I've just had a different experience. I come from almost no PL/ML background and I've found the Iterator interface in Rust(along with Option/Result) to be some of the most impressive, clear things about the language.
This kind of thing seems silly to experts but could raise the rate at which folks make it through language learning funnel.