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

Forward more Iterator methods #43074

Merged
merged 2 commits into from
Jul 15, 2017
Merged

Forward more Iterator methods #43074

merged 2 commits into from
Jul 15, 2017

Conversation

SimonSapin
Copy link
Contributor

This allows in more cases to take advantage of specific (possibly more optimized) impls of these methods, rather than the default one defined for all Iterators.

I also wanted to do this for &mut I and Box<I>, but that didn’t compile for two reasons:

  • To make the trait object-safe, generic methods (e.g. that take a closure parameter) have a where Self: Sized bound. But e.g. Box<I>: Sized does not imply I: Sized, and adding an additional bound in the impl is not allowed. Some for of specialization would be needed here.
  • With e.g. a F: FnMut(Self::Item) -> bool bound and a type Item = I::Item associated types, I got errors like F does not implement FnMut(I::Item) -> bool. This looks like a limitation in the trait resolution system not recognizing that Self::Item == I::Item or "propagating" that fact to FnMut bounds.

@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 @aturon (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@alexcrichton alexcrichton added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 6, 2017
@arielb1
Copy link
Contributor

arielb1 commented Jul 11, 2017

Is anyone going to be reviewing this? ping @aturon.

@aturon
Copy link
Member

aturon commented Jul 11, 2017

@bors: r+

Thanks @SimonSapin!

@bors
Copy link
Contributor

bors commented Jul 11, 2017

📌 Commit 758ddeb has been approved by aturon

@bors
Copy link
Contributor

bors commented Jul 12, 2017

🔒 Merge conflict

These are overridden by slice::Iter
`position` could not be implemented because calling `rposition`
on the inner iterator would require more trait bounds.
@alexcrichton
Copy link
Member

@bors: r=aturon

@bors
Copy link
Contributor

bors commented Jul 13, 2017

📌 Commit 2007987 has been approved by aturon

@Mark-Simulacrum
Copy link
Member

@bors rollup

frewsxcv added a commit to frewsxcv/rust that referenced this pull request Jul 15, 2017
Forward more Iterator methods

This allows in more cases to take advantage of specific (possibly more optimized) impls of these methods, rather than the default one defined for all `Iterator`s.

I also wanted to do this for `&mut I` and `Box<I>`, but that didn’t compile for two reasons:

* To make the trait object-safe, generic methods (e.g. that take a closure parameter) have a `where Self: Sized` bound. But e.g. `Box<I>: Sized` does not imply `I: Sized`, and adding an additional bound in the impl is not allowed. Some for of specialization would be needed here.
* With e.g. a `F: FnMut(Self::Item) -> bool` bound and a `type Item = I::Item` associated types, I got errors like `F does not implement FnMut(I::Item) -> bool`. This looks like a limitation in the trait resolution system not recognizing that `Self::Item == I::Item` or "propagating" that fact to `FnMut` bounds.
bors added a commit that referenced this pull request Jul 15, 2017
Rollup of 8 pull requests

- Successful merges: #43074, #43145, #43159, #43202, #43222, #43228, #43229, #43240
- Failed merges:
@bors
Copy link
Contributor

bors commented Jul 15, 2017

⌛ Testing commit 2007987 with merge a783fe2...

@bors bors merged commit 2007987 into rust-lang:master Jul 15, 2017
@SimonSapin SimonSapin deleted the iter branch November 16, 2017 17:50
Centril added a commit to Centril/rust that referenced this pull request Sep 5, 2019
Rev::rposition counts from the wrong end

Introduced in rust-lang#43074.

cc @SimonSapin
Centril added a commit to Centril/rust that referenced this pull request Sep 5, 2019
Rev::rposition counts from the wrong end

Introduced in rust-lang#43074.

cc @SimonSapin
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants