Skip to content

Add ExactSizeIterator implementation to Chain #124119

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

mendess
Copy link
Contributor

@mendess mendess commented Apr 18, 2024

Adds an implementation of ExactSizeIterator for Chain when both iterators implement ExactSizeIterator. Chain already implements TrustedLen this way so I think it makes sense to have this as well.

This change is insta-stable from what I could understand from the docs so it doesn't need an RFC or a ACP from what I could understand from the docs.

This is my first contribution to the standard library that actually changes the API surface of std (specifically core), so sorry if I missed something 😅

@rustbot
Copy link
Collaborator

rustbot commented Apr 18, 2024

r? @m-ou-se

rustbot has assigned @m-ou-se.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Apr 18, 2024
@rust-log-analyzer

This comment has been minimized.

@compiler-errors
Copy link
Member

See #101252 (comment)

@mendess mendess force-pushed the mendess/add-exact-size-iter-impl-to-chain branch from a7a4191 to d8ceb2d Compare April 18, 2024 14:05
@the8472
Copy link
Member

the8472 commented Apr 18, 2024

also #34433, oli might have to increment the counter :D

@mendess
Copy link
Contributor Author

mendess commented Apr 18, 2024

oops, big sad then. Closing

@mendess mendess closed this Apr 18, 2024
@Chris00
Copy link

Chris00 commented May 6, 2024

It seems this was repeatedly proposed — and I found it desiring the same feature for a particular use case. I was wondering why the contract for len() is not: the exact length unless it is equal to usize::MAX in which was it means >= usize::MAX. With such a change, infinite iterators could also be considered exact size which would be useful at times.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants