|
|
|
|
|
by pcwalton
3692 days ago
|
|
> fn cycle(self) -> Cycle<Self> where Self: Clone 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:
Where Clone is just an interface that knows how to clone its value.