@@ -144,6 +144,8 @@ pub mod structs {
144144    pub  use  crate :: with_position:: WithPosition ; 
145145    pub  use  crate :: zip_eq_impl:: ZipEq ; 
146146    pub  use  crate :: zip_longest:: ZipLongest ; 
147+     pub  use  crate :: zip_squash:: ZipSquash ; 
148+     pub  use  crate :: zip_stretch:: ZipStretch ; 
147149    pub  use  crate :: ziptuple:: Zip ; 
148150} 
149151
@@ -235,6 +237,8 @@ mod unziptuple;
235237mod  with_position; 
236238mod  zip_eq_impl; 
237239mod  zip_longest; 
240+ mod  zip_squash; 
241+ mod  zip_stretch; 
238242mod  ziptuple; 
239243
240244#[ macro_export]  
@@ -4537,10 +4541,59 @@ pub trait Itertools: Iterator {
45374541            _ => Err ( sh) , 
45384542        } 
45394543    } 
4544+ 
4545+     /// Create an iterator which iterates over both this and the specified 
4546+      /// iterator simultaneously, yielding pairs of elements. 
4547+      /// 
4548+      /// Similar to [`Iterator::zip`] except elements are evenly sampled from 
4549+      /// the longest iterator. 
4550+      /// 
4551+      /// ``` 
4552+      /// use itertools::Itertools; 
4553+      /// let a = vec![1, 2]; 
4554+      /// let b = vec![1, 2, 3]; 
4555+      /// 
4556+      /// let it = a.into_iter().zip_squash(b.into_iter()); 
4557+      /// itertools::assert_equal(it, vec![(1, 1),(2,3)]); 
4558+      /// ``` 
4559+      #[ inline]  
4560+     fn  zip_squash < J > ( self ,  other :  J )  -> ZipSquash < Self ,  J :: IntoIter > 
4561+     where 
4562+         J :  IntoIterator , 
4563+         <J  as  IntoIterator >:: IntoIter :  ExactSizeIterator , 
4564+         Self :  ExactSizeIterator  + Sized , 
4565+     { 
4566+         zip_squash:: zip_squash ( self ,  other) 
4567+     } 
4568+     /// Create an iterator which iterates over both this and the specified 
4569+      /// iterator simultaneously, yielding pairs of elements. 
4570+      /// 
4571+      /// Always yielding the first and last elements of both iterators by using [`EitherOrBoth`]. 
4572+      /// 
4573+      /// Similar to [`Itertools::zip_longest`] except elements in the shortest iterator are evenly 
4574+      /// spread. 
4575+      /// 
4576+      /// ``` 
4577+      /// use itertools::Itertools; 
4578+      /// use itertools::EitherOrBoth; 
4579+      /// let a = vec![1, 2]; 
4580+      /// let b = vec![1, 2, 3]; 
4581+      /// 
4582+      /// let it = a.into_iter().zip_stretch(b.into_iter()); 
4583+      /// itertools::assert_equal(it, vec![EitherOrBoth::Both(1, 1),EitherOrBoth::Right(2), EitherOrBoth::Both(2,3)]); 
4584+      /// ``` 
4585+      #[ inline]  
4586+     fn  zip_stretch < J > ( self ,  other :  J )  -> ZipStretch < Self ,  J :: IntoIter > 
4587+     where 
4588+         J :  IntoIterator , 
4589+         <J  as  IntoIterator >:: IntoIter :  ExactSizeIterator , 
4590+         Self :  ExactSizeIterator  + Sized , 
4591+     { 
4592+         zip_stretch:: zip_stretch ( self ,  other) 
4593+     } 
45404594} 
45414595
45424596impl < T >  Itertools  for  T  where  T :  Iterator  + ?Sized  { } 
4543- 
45444597/// Return `true` if both iterables produce equal sequences 
45454598/// (elements pairwise equal and sequences of the same length), 
45464599/// `false` otherwise. 
0 commit comments