@@ -682,7 +682,6 @@ pub struct TupleCombinations<I, T>
682
682
{
683
683
iter : T :: Combination ,
684
684
_mi : PhantomData < I > ,
685
- _mt : PhantomData < T >
686
685
}
687
686
688
687
pub trait HasCombination < I > : Sized {
@@ -698,7 +697,6 @@ pub fn tuple_combinations<T, I>(iter: I) -> TupleCombinations<I, T>
698
697
TupleCombinations {
699
698
iter : T :: Combination :: from ( iter) ,
700
699
_mi : PhantomData ,
701
- _mt : PhantomData ,
702
700
}
703
701
}
704
702
@@ -737,7 +735,7 @@ impl<I: Iterator> HasCombination<I> for (I::Item,) {
737
735
}
738
736
739
737
macro_rules! impl_tuple_combination {
740
- ( $C: ident $P: ident ; $A : ident , $ ( $I : ident ) , * ; $ ( $X: ident) * ) => (
738
+ ( $C: ident $P: ident ; $( $X: ident) * ) => (
741
739
#[ derive( Clone , Debug ) ]
742
740
pub struct $C<I : Iterator > {
743
741
item: Option <I :: Item >,
@@ -747,30 +745,25 @@ macro_rules! impl_tuple_combination {
747
745
748
746
impl <I : Iterator + Clone > From <I > for $C<I > {
749
747
fn from( mut iter: I ) -> Self {
750
- $C {
748
+ Self {
751
749
item: iter. next( ) ,
752
750
iter: iter. clone( ) ,
753
- c: $P :: from ( iter) ,
751
+ c: iter. into ( ) ,
754
752
}
755
753
}
756
754
}
757
755
758
756
impl <I : Iterator + Clone > From <I > for $C<Fuse <I >> {
759
757
fn from( iter: I ) -> Self {
760
- let mut iter = iter. fuse( ) ;
761
- $C {
762
- item: iter. next( ) ,
763
- iter: iter. clone( ) ,
764
- c: $P:: from( iter) ,
765
- }
758
+ Self :: from( iter. fuse( ) )
766
759
}
767
760
}
768
761
769
- impl <I , $ A> Iterator for $C<I >
770
- where I : Iterator <Item = $ A> + Clone ,
762
+ impl <I , A > Iterator for $C<I >
763
+ where I : Iterator <Item = A > + Clone ,
771
764
I :: Item : Clone
772
765
{
773
- type Item = ( $ ( $I ) ,* ) ;
766
+ type Item = ( A , $ ( ignore_ident! ( $X , A ) ) ,* ) ;
774
767
775
768
fn next( & mut self ) -> Option <Self :: Item > {
776
769
if let Some ( ( $( $X) ,* , ) ) = self . c. next( ) {
@@ -779,15 +772,15 @@ macro_rules! impl_tuple_combination {
779
772
} else {
780
773
self . item = self . iter. next( ) ;
781
774
self . item. clone( ) . and_then( |z| {
782
- self . c = $P :: from ( self . iter. clone( ) ) ;
775
+ self . c = self . iter. clone( ) . into ( ) ;
783
776
self . c. next( ) . map( |( $( $X) ,* , ) | ( z, $( $X) ,* ) )
784
777
} )
785
778
}
786
779
}
787
780
}
788
781
789
- impl <I , $ A> HasCombination <I > for ( $ ( $I ) ,* )
790
- where I : Iterator <Item = $ A> + Clone ,
782
+ impl <I , A > HasCombination <I > for ( A , $ ( ignore_ident! ( $X , A ) ) ,* )
783
+ where I : Iterator <Item = A > + Clone ,
791
784
I :: Item : Clone
792
785
{
793
786
type Combination = $C<Fuse <I >>;
@@ -800,25 +793,24 @@ macro_rules! impl_tuple_combination {
800
793
// use itertools::Itertools;
801
794
//
802
795
// for i in 2..=12 {
803
- // println!("impl_tuple_combination!(Tuple{arity}Combination Tuple{prev}Combination; {tys}; { idents});",
796
+ // println!("impl_tuple_combination!(Tuple{arity}Combination Tuple{prev}Combination; {idents});",
804
797
// arity = i,
805
798
// prev = i - 1,
806
- // tys = iter::repeat("A").take(i + 1).join(", "),
807
799
// idents = ('a'..'z').take(i - 1).join(" "),
808
800
// );
809
801
// }
810
802
// It could probably be replaced by a bit more macro cleverness.
811
- impl_tuple_combination ! ( Tuple2Combination Tuple1Combination ; A , A , A ; a) ;
812
- impl_tuple_combination ! ( Tuple3Combination Tuple2Combination ; A , A , A , A ; a b) ;
813
- impl_tuple_combination ! ( Tuple4Combination Tuple3Combination ; A , A , A , A , A ; a b c) ;
814
- impl_tuple_combination ! ( Tuple5Combination Tuple4Combination ; A , A , A , A , A , A ; a b c d) ;
815
- impl_tuple_combination ! ( Tuple6Combination Tuple5Combination ; A , A , A , A , A , A , A ; a b c d e) ;
816
- impl_tuple_combination ! ( Tuple7Combination Tuple6Combination ; A , A , A , A , A , A , A , A ; a b c d e f) ;
817
- impl_tuple_combination ! ( Tuple8Combination Tuple7Combination ; A , A , A , A , A , A , A , A , A ; a b c d e f g) ;
818
- impl_tuple_combination ! ( Tuple9Combination Tuple8Combination ; A , A , A , A , A , A , A , A , A , A ; a b c d e f g h) ;
819
- impl_tuple_combination ! ( Tuple10Combination Tuple9Combination ; A , A , A , A , A , A , A , A , A , A , A ; a b c d e f g h i) ;
820
- impl_tuple_combination ! ( Tuple11Combination Tuple10Combination ; A , A , A , A , A , A , A , A , A , A , A , A ; a b c d e f g h i j) ;
821
- impl_tuple_combination ! ( Tuple12Combination Tuple11Combination ; A , A , A , A , A , A , A , A , A , A , A , A , A ; a b c d e f g h i j k) ;
803
+ impl_tuple_combination ! ( Tuple2Combination Tuple1Combination ; a) ;
804
+ impl_tuple_combination ! ( Tuple3Combination Tuple2Combination ; a b) ;
805
+ impl_tuple_combination ! ( Tuple4Combination Tuple3Combination ; a b c) ;
806
+ impl_tuple_combination ! ( Tuple5Combination Tuple4Combination ; a b c d) ;
807
+ impl_tuple_combination ! ( Tuple6Combination Tuple5Combination ; a b c d e) ;
808
+ impl_tuple_combination ! ( Tuple7Combination Tuple6Combination ; a b c d e f) ;
809
+ impl_tuple_combination ! ( Tuple8Combination Tuple7Combination ; a b c d e f g) ;
810
+ impl_tuple_combination ! ( Tuple9Combination Tuple8Combination ; a b c d e f g h) ;
811
+ impl_tuple_combination ! ( Tuple10Combination Tuple9Combination ; a b c d e f g h i) ;
812
+ impl_tuple_combination ! ( Tuple11Combination Tuple10Combination ; a b c d e f g h i j) ;
813
+ impl_tuple_combination ! ( Tuple12Combination Tuple11Combination ; a b c d e f g h i j k) ;
822
814
823
815
/// An iterator adapter to filter values within a nested `Result::Ok`.
824
816
///
0 commit comments