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

Implement nth and nth_back for list and tuple iterators #4787

Open
ngoldbaum opened this issue Dec 10, 2024 · 1 comment
Open

Implement nth and nth_back for list and tuple iterators #4787

ngoldbaum opened this issue Dec 10, 2024 · 1 comment

Comments

@ngoldbaum
Copy link
Contributor

ngoldbaum commented Dec 10, 2024

Right now BoundListIterator::nth will call next n times (I think, please correct me if I'm misinterpreting), when instead it could get the nth item immediately. We should override Iterator::nth and DoubleEndedIterator::nth_back on stable rust and Iterator::advance_by and DoubleEndedIterator::advance_back_by on nightly rust to do constant-time indexing for all of the list and tuple iterator stucts.

@ngoldbaum ngoldbaum changed the title Implement nth and nth_back for list and tuple iterators Implement nth and nth_back for list and tuple iterators Dec 10, 2024
@bschoenmaeckers
Copy link
Contributor

bschoenmaeckers commented Dec 11, 2024

Same can be done with last()

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

No branches or pull requests

2 participants