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 #614

Merged
merged 3 commits into from Apr 19, 2019
Merged

Forward more iterator methods #614

merged 3 commits into from Apr 19, 2019

Conversation

andrei-papou
Copy link
Contributor

@andrei-papou andrei-papou commented Apr 3, 2019

Fixes #555

Forwarded the following Iter and IterMut methods to the inner iterator:

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

Andrew and others added 2 commits April 3, 2019 11:54
Merge main rep master to fork master
- nth
- collect
- any
- all
- find
- find_map
Copy link
Member

@jturner314 jturner314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a few comments (primarily removing unnecessary Self: Sized bounds). Additional methods that would be good to forward are:

  • count
  • last
  • position
  • rposition

src/iterators/mod.rs Outdated Show resolved Hide resolved
src/iterators/mod.rs Outdated Show resolved Hide resolved
src/iterators/mod.rs Outdated Show resolved Hide resolved
src/iterators/mod.rs Outdated Show resolved Hide resolved
src/iterators/mod.rs Outdated Show resolved Hide resolved
src/iterators/mod.rs Outdated Show resolved Hide resolved
src/iterators/mod.rs Outdated Show resolved Hide resolved
src/iterators/mod.rs Outdated Show resolved Hide resolved
src/iterators/mod.rs Outdated Show resolved Hide resolved
src/iterators/mod.rs Outdated Show resolved Hide resolved
@andrei-papou
Copy link
Contributor Author

@jturner314 I've removed Self bounds and forwarded all the methods you've mentioned except rposition. I'm not sure if we can forward it since it requires DoubleEndedIterator bound on Self, but DoubleEndedIterator is only implemented for Iter<'a, A, Ix1>. I've tried the following solutions:

  1. Add more specific Iterator impl for Iter<'a, A, Ix1>. It does not work because this impl overlaps with the general one for Iter<'a, A, D>.
  2. Add special marker trait (for example FlatDimension), impl it only for Ix1 and add a bound D: FlatDimension to the rposition where clause. This also does not work because Rust does not allow method bound to be stricter than trait bound.

Copy link
Member

@jturner314 jturner314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I didn't realize that about rposition. I think you're right that we can't provide a specialized implementation for it.

Everything looks good to me. I'll wait a little while to give anyone else a chance to comment, then I'll merge this.

Thanks!

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

Successfully merging this pull request may close these issues.

Forward more iterator methods for element iterators
2 participants