@@ -626,7 +626,9 @@ impl<A, B> DoubleEndedIterator for Chain<A, B> where
626
626
pub struct Zip < A , B > {
627
627
a : A ,
628
628
b : B ,
629
- spec : <( A , B ) as ZipImplData >:: Data ,
629
+ // index and len are only used by the specialized version of zip
630
+ index : usize ,
631
+ len : usize ,
630
632
}
631
633
632
634
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -668,17 +670,6 @@ trait ZipImpl<A, B> {
668
670
B : DoubleEndedIterator + ExactSizeIterator ;
669
671
}
670
672
671
- // Zip specialization data members
672
- #[ doc( hidden) ]
673
- trait ZipImplData {
674
- type Data : ' static + Clone + Default + fmt:: Debug ;
675
- }
676
-
677
- #[ doc( hidden) ]
678
- impl < T > ZipImplData for T {
679
- default type Data = ( ) ;
680
- }
681
-
682
673
// General Zip impl
683
674
#[ doc( hidden) ]
684
675
impl < A , B > ZipImpl < A , B > for Zip < A , B >
@@ -689,7 +680,8 @@ impl<A, B> ZipImpl<A, B> for Zip<A, B>
689
680
Zip {
690
681
a : a,
691
682
b : b,
692
- spec : Default :: default ( ) , // unused
683
+ index : 0 , // unused
684
+ len : 0 , // unused
693
685
}
694
686
}
695
687
@@ -742,20 +734,6 @@ impl<A, B> ZipImpl<A, B> for Zip<A, B>
742
734
}
743
735
}
744
736
745
- #[ doc( hidden) ]
746
- #[ derive( Default , Debug , Clone ) ]
747
- struct ZipImplFields {
748
- index : usize ,
749
- len : usize ,
750
- }
751
-
752
- #[ doc( hidden) ]
753
- impl < A , B > ZipImplData for ( A , B )
754
- where A : TrustedRandomAccess , B : TrustedRandomAccess
755
- {
756
- type Data = ZipImplFields ;
757
- }
758
-
759
737
#[ doc( hidden) ]
760
738
impl < A , B > ZipImpl < A , B > for Zip < A , B >
761
739
where A : TrustedRandomAccess , B : TrustedRandomAccess
@@ -765,18 +743,16 @@ impl<A, B> ZipImpl<A, B> for Zip<A, B>
765
743
Zip {
766
744
a : a,
767
745
b : b,
768
- spec : ZipImplFields {
769
- index : 0 ,
770
- len : len,
771
- }
746
+ index : 0 ,
747
+ len : len,
772
748
}
773
749
}
774
750
775
751
#[ inline]
776
752
fn next ( & mut self ) -> Option < ( A :: Item , B :: Item ) > {
777
- if self . spec . index < self . spec . len {
778
- let i = self . spec . index ;
779
- self . spec . index += 1 ;
753
+ if self . index < self . len {
754
+ let i = self . index ;
755
+ self . index += 1 ;
780
756
unsafe {
781
757
Some ( ( self . a . get_unchecked ( i) , self . b . get_unchecked ( i) ) )
782
758
}
@@ -787,7 +763,7 @@ impl<A, B> ZipImpl<A, B> for Zip<A, B>
787
763
788
764
#[ inline]
789
765
fn size_hint ( & self ) -> ( usize , Option < usize > ) {
790
- let len = self . spec . len - self . spec . index ;
766
+ let len = self . len - self . index ;
791
767
( len, Some ( len) )
792
768
}
793
769
@@ -796,9 +772,9 @@ impl<A, B> ZipImpl<A, B> for Zip<A, B>
796
772
where A : DoubleEndedIterator + ExactSizeIterator ,
797
773
B : DoubleEndedIterator + ExactSizeIterator
798
774
{
799
- if self . spec . index < self . spec . len {
800
- self . spec . len -= 1 ;
801
- let i = self . spec . len ;
775
+ if self . index < self . len {
776
+ self . len -= 1 ;
777
+ let i = self . len ;
802
778
unsafe {
803
779
Some ( ( self . a . get_unchecked ( i) , self . b . get_unchecked ( i) ) )
804
780
}
0 commit comments