-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Conversation
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. |
Is anyone going to be reviewing this? ping @aturon. |
@bors: r+ Thanks @SimonSapin! |
📌 Commit 758ddeb has been approved by |
🔒 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.
@bors: r=aturon |
📌 Commit 2007987 has been approved by |
@bors rollup |
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.
Rev::rposition counts from the wrong end Introduced in rust-lang#43074. cc @SimonSapin
Rev::rposition counts from the wrong end Introduced in rust-lang#43074. cc @SimonSapin
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
andBox<I>
, but that didn’t compile for two reasons:where Self: Sized
bound. But e.g.Box<I>: Sized
does not implyI: Sized
, and adding an additional bound in the impl is not allowed. Some for of specialization would be needed here.F: FnMut(Self::Item) -> bool
bound and atype Item = I::Item
associated types, I got errors likeF does not implement FnMut(I::Item) -> bool
. This looks like a limitation in the trait resolution system not recognizing thatSelf::Item == I::Item
or "propagating" that fact toFnMut
bounds.