-
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
Specialize methods on iter::Cloned<I> where I::Item: Copy. #39022
Conversation
Instead of cloning a bunch of copyable types only to drop them (in `nth`, `last`, and `count`), take advantage of rust-lang#1521 (Copy clone semantics) and don't bother cloning them in the first place (directly call `nth`, `last`, and `count` on the wrapped iterator). If the wrapped iterator optimizes these methods, `Cloned` now inherits this optimization.
(rust_highfive has picked a reviewer for you, use r? to override) |
As per the last attempt, cc @rust-lang/libs, @bluss. Also, please wait for travis. (*edit* apparently I can't call teams :( ) |
#1521 seems to be the wrong issue? |
See #28125. Would be a shame to block such lib-opts on that though, but it has already happened. |
Since #28125 was closed, RFC 1521 (most likely what @Stebalien meant by "#1521") has been written and accepted, which does allow library code to assume |
Aw, right; totally forgot about that. |
@rkruppe Yes. Sorry about that @Mark-Simulacrum. |
The error on Travis seems worrisome? |
If nothing else, this PR is a good way to find bugs... Closed waiting on #39025. |
Actually, that's just a dup of #36804. |
Instead of cloning a bunch of copyable types only to drop them (in
nth
,last
, andcount
), take advantage of RFC 1521 (Copy clone semantics) and don't bother cloning them in the first place (directly callnth
,last
, andcount
on the wrapped iterator). If the wrapped iterator optimizes these methods,Cloned
now inherits this optimization.This is a retry of #36791. It was blocked waiting for fixes for #36053 and #36848 to make it into a beta snapshot.