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

Forward more iterator methods for element iterators #555

Closed
bluss opened this issue Nov 21, 2018 · 2 comments · Fixed by #614
Closed

Forward more iterator methods for element iterators #555

bluss opened this issue Nov 21, 2018 · 2 comments · Fixed by #614

Comments

@bluss
Copy link
Member

bluss commented Nov 21, 2018

The Iter and IterMut are composed of a contiguous case and a general case, and because of this we should forward most (non-adaptor) methods to the underlying iterators. The existing fold and rfold methods serve as examples. No new custom implementations of the methods are needed in ElementsBase or Baseiter.

The ultimate ones to forward are try_fold and try_rfold, but they need to wait for having stable signatures (all traits in the signature).

Good ones to forward:

  • nth
  • collect
  • all, any
  • find, find_map

Some don't matter because they use fold that we already forward: count, max, min, max_by etc, sum, product

@andrei-papou
Copy link
Contributor

Hi @bluss . I'd like to pick this one up.

@jturner314
Copy link
Member

@andrei-papou That would be great.

Regarding with methods to forward, @bluss has provided some good suggestions. If you'd like to investigate yourself, I recommend looking at the methods std::slice::Iter overrides and, since we can't yet forward try_fold and try_rfold, the methods of Iterator and DoubleEndedIterator that are implemented in terms of try_fold and try_rfold.

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

Successfully merging a pull request may close this issue.

3 participants