[no description]
Diffstat (limited to 'src/iterator.rs')
| -rw-r--r-- | src/iterator.rs | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/iterator.rs b/src/iterator.rs index f288943..56a441a 100644 --- a/src/iterator.rs +++ b/src/iterator.rs @@ -1,5 +1,5 @@ #![allow(nonstandard_style)] -use crate::{MapAllMut, Pick, RePick, Tupl}; +use crate::{MapAllMut, Pick, RePick, Tupl, fns}; pub trait IteratorOfTuplesWithF<retval>: Iterator<Item: Tupl> + Sized { @@ -14,11 +14,7 @@ pub trait IteratorOfTuplesWithF<retval>: where Self::Item: RePick<N, retval>, { - self.map(move |x| { - let (l, at, r) = x.depict(); - let at = f(at); - Self::Item::unpick(l, at, r) - }) + self.map(fns::at::<N, _, _>(f)) } /// filter map the item at: (|(x, y)| f(x).zip(Some(y)) fn filter_map_at<const N: usize>( @@ -173,12 +169,12 @@ pub trait $name2<'a, T: Tupl + 'a, retval>: self.$convert().map_at(f) } /// map the item to just one, then map that one: (|x| f(x.0)) - fn map_on<const N: usize, U>( + fn map_on<const N: usize>( self, - f: impl FnMut(<T::$ref<'a> as Pick<N>>::At) -> U, + f: impl FnMut(<T::$ref<'a> as Pick<N>>::At) -> retval, ) -> core::iter::Map< impl Iterator<Item = <T::$ref<'a> as Pick<N>>::At>, - impl FnMut(<T::$ref<'a> as Pick<N>>::At) -> U, + impl FnMut(<T::$ref<'a> as Pick<N>>::At) -> retval, > where T::$ref<'a>: Pick<N>, @@ -223,4 +219,6 @@ fn x() { .map_all((|x| x + 1, |x| x.to_uppercase())) .next_chunk::<2>() .unwrap(); + + [(1, 2)].iter().map_on::<0>(|x| x + 2); } |