Skip to content
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

Propagate ExactSizeIterator up from Chain's iterators #101252

Closed
wants to merge 3 commits into from

Conversation

Aceeri
Copy link

@Aceeri Aceeri commented Aug 31, 2022

Wasn't entirely sure if this was intentional but noticed that Chain does not implement ExactSizeIterator if their internal iterators do.

I leave the implementation up to the existing size_hint.

@rustbot rustbot added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Aug 31, 2022
@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @joshtriplett (or someone else) soon.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 31, 2022
@clarfonthey
Copy link
Contributor

I'm in favour of this, but it's worth pointing out the discussion in #34433 for why this wasn't merged before.

@Aceeri
Copy link
Author

Aceeri commented Aug 31, 2022

Ah hmm... didn't expect this rabbit hole to go so far.

@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-13 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
   Compiling unwind v0.0.0 (/checkout/library/unwind)
error: implementation has missing stability attribute
   --> library/core/src/iter/adapters/chain.rs:285:1
    |
285 | / impl<A, B> ExactSizeIterator for Chain<A, B>
286 | | where
287 | |     A: ExactSizeIterator,
288 | |     B: ExactSizeIterator,
289 | | {
    | |_^


error[E0271]: type mismatch resolving `<B as Iterator>::Item == <A as Iterator>::Item`
    |
    |
285 | impl<A, B> ExactSizeIterator for Chain<A, B>
    |      -  -  ^^^^^^^^^^^^^^^^^ expected type parameter `A`, found type parameter `B`
    |      |  found type parameter
    |      expected type parameter
    |
    = note: expected associated type `<A as Iterator>::Item`
    = note: expected associated type `<A as Iterator>::Item`
               found associated type `<B as Iterator>::Item`
    = note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound
    = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters
note: required because of the requirements on the impl of `Iterator` for `Chain<A, B>`
    |
    |
41  | impl<A, B> Iterator for Chain<A, B>
note: required by a bound in `ExactSizeIterator`
   --> library/core/src/iter/traits/exact_size.rs:76:30
    |
76  | pub trait ExactSizeIterator: Iterator {

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.

6 participants