-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Improve documentation on what len() on ExactSizeIterator means #66491
Comments
Implementations of That being said, the documentation for |
Hm, seeing as |
Unsafe code can't rely on The length of an iterator is defined as the number of items yielded before it returns None, so Fuse's implementation is correct. |
Oh my bad, I was confusing it with TrustedLen. |
Ok, makes sense. But I will be pedantic here since I prefer documentation to have slightly more formal flavor.
The
Now resume can be interpreted as continuing the the previous iteration instead of starting a new iteration (conceptually a new iteration would require a new iterator then). Under this interpretation The documentation could use a more precise definition of what an iteration is and that resumption is really considered a new iteration. |
If the wrapped iterator implements
ExactSizeIterator
thenFuse
blindly delegateslen()
to it. The underlying iterator may know its exact size but return spuriousNone
results anyway, on whichFuse
will stop iterating even though the source knows that there are elements left to iterate, meaningFuse
will indicate that there are elements left but never return them.The behavior was introduced in #37944 but didn't see any discussion.
Playground demo
The text was updated successfully, but these errors were encountered: