Closed Philippe-Cholet closed 8 months ago
Without Clone
-able values, iterate
and successors
are forced to compute it ahead-of-time while we still have access to the value, it's the trade-off: not cloned but ahead-of-time computation. But being able to return None
in successors
' closure seems a better API decision to me.
EDIT: Not being able to stop the iterator with None
kinda suppose it can continue forever (Iterate::size_hint
explicitly says it).
The working example of iterate
seems more like a successors
example to me.
iterate(1, |n| (n + 1) % 3)
would be appropriate to me.
... It lead me to change the working example to better describe iterate
vs successors
.
It could be something different than basically (1..=3).cycle()
though.
Resolves #600. See https://github.com/rust-itertools/itertools/issues/600#issuecomment-1884539907 for why I don't see an alternative.