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
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions src/iterators/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ mod windows;
mod lanes;
pub mod iter;

use std::iter::FromIterator;
use std::marker::PhantomData;
use std::ptr;

Expand Down Expand Up @@ -388,6 +389,38 @@ impl<'a, A, D: Dimension> Iterator for Iter<'a, A, D> {
{
either!(self.inner, iter => iter.fold(init, g))
}

fn nth(&mut self, n: usize) -> Option<Self::Item> {
either_mut!(self.inner, iter => iter.nth(n))
}

fn collect<B: FromIterator<Self::Item>>(self) -> B where Self: Sized {
jturner314 marked this conversation as resolved.
Show resolved Hide resolved
either!(self.inner, iter => iter.collect())
}

fn all<F>(&mut self, f: F) -> bool
where Self: Sized, F: FnMut(Self::Item) -> bool
jturner314 marked this conversation as resolved.
Show resolved Hide resolved
{
either_mut!(self.inner, iter => iter.all(f))
}

fn any<F>(&mut self, f: F) -> bool
where Self: Sized, F: FnMut(Self::Item) -> bool
jturner314 marked this conversation as resolved.
Show resolved Hide resolved
{
either_mut!(self.inner, iter => iter.any(f))
}

fn find<P>(&mut self, predicate: P) -> Option<Self::Item>
where Self: Sized, P: FnMut(&Self::Item) -> bool
jturner314 marked this conversation as resolved.
Show resolved Hide resolved
{
either_mut!(self.inner, iter => iter.find(predicate))
}

fn find_map<B, F>(&mut self, f: F) -> Option<B>
where Self: Sized, F: FnMut(Self::Item) -> Option<B>
jturner314 marked this conversation as resolved.
Show resolved Hide resolved
{
either_mut!(self.inner, iter => iter.find_map(f))
}
}

impl<'a, A> DoubleEndedIterator for Iter<'a, A, Ix1> {
Expand Down Expand Up @@ -455,6 +488,38 @@ impl<'a, A, D: Dimension> Iterator for IterMut<'a, A, D> {
{
either!(self.inner, iter => iter.fold(init, g))
}

fn nth(&mut self, n: usize) -> Option<Self::Item> {
either_mut!(self.inner, iter => iter.nth(n))
}

fn collect<B: FromIterator<Self::Item>>(self) -> B where Self: Sized {
jturner314 marked this conversation as resolved.
Show resolved Hide resolved
either!(self.inner, iter => iter.collect())
}

fn all<F>(&mut self, f: F) -> bool
where Self: Sized, F: FnMut(Self::Item) -> bool
jturner314 marked this conversation as resolved.
Show resolved Hide resolved
{
either_mut!(self.inner, iter => iter.all(f))
}

fn any<F>(&mut self, f: F) -> bool
where Self: Sized, F: FnMut(Self::Item) -> bool
jturner314 marked this conversation as resolved.
Show resolved Hide resolved
{
either_mut!(self.inner, iter => iter.any(f))
}

fn find<P>(&mut self, predicate: P) -> Option<Self::Item>
where Self: Sized, P: FnMut(&Self::Item) -> bool
jturner314 marked this conversation as resolved.
Show resolved Hide resolved
{
either_mut!(self.inner, iter => iter.find(predicate))
}

fn find_map<B, F>(&mut self, f: F) -> Option<B>
where Self: Sized, F: FnMut(Self::Item) -> Option<B>
jturner314 marked this conversation as resolved.
Show resolved Hide resolved
{
either_mut!(self.inner, iter => iter.find_map(f))
}
}

impl<'a, A> DoubleEndedIterator for IterMut<'a, A, Ix1> {
Expand Down