Skip to content

Specialize Iterator::last for DoubleEndedIterator. #42584

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

Closed
wants to merge 1 commit into from

Conversation

clarfonthey
Copy link
Contributor

Fixes #41691.

This optimisation has been applied manually on a lot of different iterators, including some in the standard library, but it makes more sense to do it automatically with specialisation.

@rust-highfive
Copy link
Contributor

r? @BurntSushi

(rust_highfive has picked a reviewer for you, use r? to override)

@ollie27
Copy link
Member

ollie27 commented Jun 10, 2017

This is a breaking change for iterators with side effects.

@clarfonthey
Copy link
Contributor Author

clarfonthey commented Jun 10, 2017

@ollie27 what exactly do you mean? iterators like Drain and the like will still drop their contents as expected

(we can still do a crater run and check this first)

@ollie27
Copy link
Member

ollie27 commented Jun 10, 2017

Things like (0..10).map(|x| { println!("{}", x); x }).last() would change behaviour.

@nagisa
Copy link
Member

nagisa commented Jun 10, 2017

Yeah, we cannot land this. Similar specialisations have been proposed multiple times already and have been rejected.

I have a similar specialisation for specifically ranges in my Range PR.

I’ll close because there’s no way this will be approved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants