diff --git a/src/zipcartesian.rs b/src/zipcartesian.rs index 77ce92b..0aae18b 100644 --- a/src/zipcartesian.rs +++ b/src/zipcartesian.rs @@ -1,24 +1,34 @@ use std::iter::Iterator; -pub trait ZipCartesianExt: Iterator { +pub trait ZipCartesianExt: Iterator + Clone +where + Self::Item: Copy, +{ fn zip_cartesian( self, b: B, ) -> impl Iterator + Clone where - Self::Item: Copy, - Self: Sized + Clone, - B: Iterator + Clone; + B::Item: Copy, + B: Iterator + Clone; } -impl + Clone> ZipCartesianExt for I { +impl ZipCartesianExt for I +where + I: Iterator + Clone, + I::Item: Copy, +{ /// Exhaustive coupling of two iterators. /// For each x in `self`: for each y in `b`: yield (x, y). /// b: B must implement `Clone`. - fn zip_cartesian + Clone>( + fn zip_cartesian( self, b: B, - ) -> impl Iterator + Clone { + ) -> impl Iterator + Clone + where + B::Item: Copy, + B: Iterator + Clone, + { self.flat_map(move |a_item| { b.clone().map(move |b_item| (a_item, b_item)) })