-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
specify that Iterators.rest
must be given a valid state
#58962
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Tangentially, but it is kind of ugly how this wants an explicit state passed in (and how the docstring uses the function). I don't think the value of the state has any meaning outside how it should be used in the iteration protocol, or? |
I agree, and as far as I can see it's the only iterator with an API like that. I guess it's to draw a distinction with but anyway that's probably not changeable, so I just wanted to make it harder to hit infinite loops |
Maybe it is worth adding to the docstring that you should have received that state from an |
64a3183
to
3c65d85
Compare
is the fact that but pretty much any implementation of |
This is the way. But stronger: It's not really different from I honestly don't think it's worth trying to protect against this case, particularly because Ideally, iterators would always return |
3c65d85
to
aeb2a77
Compare
aeb2a77
to
4bc0006
Compare
Iterators.rest
must be given a valid state
ok, fair enough. I've amended the PR to just make the docstring a bit more emphatic about the |
I can't quite reach into the example to suggest a change there, but let's also have that example use a |
currentlyIterators.rest(1:2, 3)
creates an infinite loop. after this PR it would be anArgumentError
docs only now