-
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
Add Iterator::max_size_hint #57360
Add Iterator::max_size_hint #57360
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
c8dc788
to
c0d0a75
Compare
This comment has been minimized.
This comment has been minimized.
How does this square with boat's comment about object safety? |
I'm pretty sure the upper bounds are (sadly) completely unused: https://internals.rust-lang.org/t/is-size-hint-1-ever-used/8187?u=scottmcm So I'm not sure how much good this will do in practice, much as I like it in theory. |
a4d8e11
to
8132f5a
Compare
You're right-- I've changed from a constant to a method instead. This limits its use in constants until some version of |
8132f5a
to
3d1194c
Compare
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
43ea988
to
bc01591
Compare
☔ The latest upstream changes (presumably #57577) made this pull request unmergeable. Please resolve the merge conflicts. |
bc01591
to
eb18ed3
Compare
Rebased. Is there something wrong with the current implementation of |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
☔ The latest upstream changes (presumably #55045) made this pull request unmergeable. Please resolve the merge conflicts. |
eb18ed3
to
b8cfa89
Compare
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
b8cfa89
to
200d71b
Compare
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
ping from triage @clarcharr @alexcrichton any updates on this? |
I wonder if this would perhaps be best moved to an internals thread or an issue? The description of this PR indicates it's largely here for discussion, but it doesn't seem to have a lot of discussion. |
Honestly? That's reasonable. I'm just going to close this for now because I don't really have the energy to start a discussion for the time being, although I'll revisit this at some point if no one else does. |
This is an alternative to #48544 (since closed) which adds a
max_size_hint
method toIterator
. It should be merged after #56932, and the actual change is in commit 21348899c7c3068028d6c490edd3482f5e6392bb.The idea of a "minimum size" is confusing for iterators and iterables, because it's unclear where this should exactly be described. However, the maximum size is unambiguous and will improve the upper bound hints for
flatten
andflat_map
.I figured that I'd create a PR here so that people can discuss the change, even though it probably won't be added immediately.