-
Notifications
You must be signed in to change notification settings - Fork 13.3k
specialize Iterator::nth for Cycles over ExactSizeIterators to #47555
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
reduce clones at the cost of one remainder. This should be faster in most cases and may in some situations reduce memory churn via clones.
(rust_highfive has picked a reviewer for you, use r? to override) |
This is subject to the same discussion as in #47533, concerning observability of |
src/libcore/iter/mod.rs
Outdated
#[stable(feature = "rust1", since = "1.0.0")] | ||
impl<I> Iterator for Cycle<I> | ||
where I: Clone + Iterator + ExactSizeIterator, | ||
<I as Iterator>::Item : Clone + Copy { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be just I::Item: Copy
style wise. Iterator + ExactSizeIterator
is also redundant, just ExactSizeIterator
is the same.
Omitting Clone calls for Current implementation omits the clones of the iterator itself, so a motivation is needed for that too. |
Thank you for the review! We require Regarding the iterator, I can change it to require |
Iterators aren't |
Too true, I better revert that one. So since we cannot require |
Ping from triage, @bluss — new commits up for you to review! |
I think the same applies as in the other PRs, see this comment #47533 (comment) |
Ping from triage @bluss @llogiq! Given the linked comment #47533 (comment), I guess this PR should be closed since clones of the iterator itself are still elided, and an RFC detailing whether clone elision is acceptable should be accepted before this PR can be reconsidered? |
Until we all reach decision |
reduce clones at the cost of one remainder. This should be faster in most cases and may in some situations reduce memory churn via clones.