3 ms·
Yup, I've got the same feeling here. If you've spent more than a cursory time with Rust this is pretty straightforward. You'd represent this in Java(minus mov
by vvanders 10y ago
Yup, I've got the same feeling here.
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.
- Lewisham 10y agoFair enough; some more noodling over the signature made it a bit more obvious than it seemed banged out at the back of an OSCON presentation. I think the point still holds. Maybe just not for that one.
- vvanders 10y agoThe thing is what you linked is the docs of an implementation not the interface. 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.