use crate::{Pick, RePick, Tupl}; /// may add more later pub trait IteratorOfTuples: Iterator { /// Map the item at: (|(x, y)| (f(x), y)) fn map_at( self, f: impl FnMut(>::At) -> U, ) -> impl Iterator>::New> where Self::Item: RePick; /// make it just one: (|x| x.0) fn just( self, ) -> impl Iterator>::At> where Self::Item: Pick; /// map the item to just one, then map that one: (|x| f(x.0)) fn map_just( self, f: impl FnMut(>::At) -> U, ) -> core::iter::Map< impl Iterator>::At>, impl FnMut(>::At) -> U, > where Self: Iterator> + Sized, { self.just().map(f) } } impl> IteratorOfTuples for I { #[expect(refining_impl_trait)] fn map_at( self, mut f: impl FnMut(>::At) -> U, ) -> core::iter::Map< I, impl FnMut( ::Item, ) -> <::Item as RePick>::New, > where Self::Item: RePick, { self.map(move |x| { let (l, at, r) = x.depict(); let at = f(at); Self::Item::unpick(l, at, r) }) } #[expect(refining_impl_trait)] fn just( self, ) -> core::iter::Map< I, impl FnMut(::Item) -> <::Item as Pick>::At, > where Self::Item: Pick, { self.map(|x| x.pick()) } }