@@ -55,7 +55,7 @@ pub trait IteratorUtil<A> {
5555 /// assert_eq!(it.next().get(), &1);
5656 /// assert!(it.next().is_none());
5757 /// ~~~
58- fn chain < U : Iterator < A > > ( self , other : U ) -> ChainIterator < Self , U > ;
58+ fn chain < U : Iterator < A > > ( self , other : U ) -> ChainIterator < A , Self , U > ;
5959
6060 /// Creates an iterator which iterates over both this and the specified
6161 /// iterators simultaneously, yielding the two elements as pairs. When
@@ -73,7 +73,7 @@ pub trait IteratorUtil<A> {
7373 /// assert_eq!(it.next().get(), (&0, &1));
7474 /// assert!(it.next().is_none());
7575 /// ~~~
76- fn zip < B , U : Iterator < B > > ( self , other : U ) -> ZipIterator < Self , U > ;
76+ fn zip < B , U : Iterator < B > > ( self , other : U ) -> ZipIterator < A , Self , B , U > ;
7777
7878 // FIXME: #5898: should be called map
7979 /// Creates a new iterator which will apply the specified function to each
@@ -139,7 +139,7 @@ pub trait IteratorUtil<A> {
139139 /// assert_eq!(it.next().get(), (1, &200));
140140 /// assert!(it.next().is_none());
141141 /// ~~~
142- fn enumerate ( self ) -> EnumerateIterator < Self > ;
142+ fn enumerate ( self ) -> EnumerateIterator < A , Self > ;
143143
144144 /// Creates an iterator which invokes the predicate on elements until it
145145 /// returns true. Once the predicate returns true, all further elements are
@@ -285,7 +285,8 @@ pub trait IteratorUtil<A> {
285285 /// let a = [1, 2, 3, 4, 5];
286286 /// assert!(a.iter().last().get() == &5);
287287 /// ~~~
288- fn last ( & mut self ) -> Option < A > ;
288+ // FIXME: #5898: should be called `last`
289+ fn last_ ( & mut self ) -> Option < A > ;
289290
290291 /// Performs a fold operation over the entire iterator, returning the
291292 /// eventual state at the end of the iteration.
@@ -349,12 +350,12 @@ pub trait IteratorUtil<A> {
349350/// In the future these will be default methods instead of a utility trait.
350351impl < A , T : Iterator < A > > IteratorUtil < A > for T {
351352 #[ inline( always) ]
352- fn chain < U : Iterator < A > > ( self , other : U ) -> ChainIterator < T , U > {
353+ fn chain < U : Iterator < A > > ( self , other : U ) -> ChainIterator < A , T , U > {
353354 ChainIterator { a : self , b : other, flag : false }
354355 }
355356
356357 #[ inline( always) ]
357- fn zip < B , U : Iterator < B > > ( self , other : U ) -> ZipIterator < T , U > {
358+ fn zip < B , U : Iterator < B > > ( self , other : U ) -> ZipIterator < A , T , B , U > {
358359 ZipIterator { a : self , b : other}
359360 }
360361
@@ -375,7 +376,7 @@ impl<A, T: Iterator<A>> IteratorUtil<A> for T {
375376 }
376377
377378 #[ inline( always) ]
378- fn enumerate ( self ) -> EnumerateIterator < T > {
379+ fn enumerate ( self ) -> EnumerateIterator < A , T > {
379380 EnumerateIterator { iter : self , count : 0 }
380381 }
381382
@@ -437,7 +438,7 @@ impl<A, T: Iterator<A>> IteratorUtil<A> for T {
437438
438439 /// Return the last item yielded by an iterator.
439440 #[ inline( always) ]
440- fn last ( & mut self ) -> Option < A > {
441+ fn last_ ( & mut self ) -> Option < A > {
441442 let mut last = None ;
442443 for self . advance |x| { last = Some ( x) ; }
443444 last
@@ -570,13 +571,14 @@ impl<A: Ord, T: Iterator<A>> OrdIterator<A> for T {
570571}
571572
572573/// An iterator which strings two iterators together
573- pub struct ChainIterator < T , U > {
574+ // FIXME #6967: Dummy A parameter to get around type inference bug
575+ pub struct ChainIterator < A , T , U > {
574576 priv a: T ,
575577 priv b: U ,
576578 priv flag : bool
577579}
578580
579- impl < A , T : Iterator < A > , U : Iterator < A > > Iterator < A > for ChainIterator < T , U > {
581+ impl < A , T : Iterator < A > , U : Iterator < A > > Iterator < A > for ChainIterator < A , T , U > {
580582 #[ inline]
581583 fn next ( & mut self ) -> Option < A > {
582584 if self . flag {
@@ -593,12 +595,13 @@ impl<A, T: Iterator<A>, U: Iterator<A>> Iterator<A> for ChainIterator<T, U> {
593595}
594596
595597/// An iterator which iterates two other iterators simultaneously
596- pub struct ZipIterator < T , U > {
598+ // FIXME #6967: Dummy A & B parameters to get around type inference bug
599+ pub struct ZipIterator < A , T , B , U > {
597600 priv a: T ,
598601 priv b: U
599602}
600603
601- impl < A , B , T : Iterator < A > , U : Iterator < B > > Iterator < ( A , B ) > for ZipIterator < T , U > {
604+ impl < A , B , T : Iterator < A > , U : Iterator < B > > Iterator < ( A , B ) > for ZipIterator < A , T , B , U > {
602605 #[ inline]
603606 fn next ( & mut self ) -> Option < ( A , B ) > {
604607 match ( self . a . next ( ) , self . b . next ( ) ) {
@@ -664,12 +667,13 @@ impl<'self, A, B, T: Iterator<A>> Iterator<B> for FilterMapIterator<'self, A, B,
664667}
665668
666669/// An iterator which yields the current count and the element during iteration
667- pub struct EnumerateIterator < T > {
670+ // FIXME #6967: Dummy A parameter to get around type inference bug
671+ pub struct EnumerateIterator < A , T > {
668672 priv iter : T ,
669673 priv count : uint
670674}
671675
672- impl < A , T : Iterator < A > > Iterator < ( uint , A ) > for EnumerateIterator < T > {
676+ impl < A , T : Iterator < A > > Iterator < ( uint , A ) > for EnumerateIterator < A , T > {
673677 #[ inline]
674678 fn next ( & mut self ) -> Option < ( uint , A ) > {
675679 match self . iter . next ( ) {
@@ -887,7 +891,7 @@ mod tests {
887891 let expected = [ 0 , 1 , 2 , 3 , 4 , 5 , 30 , 40 , 50 , 60 ] ;
888892 let mut it = xs. iter( ) . chain( ys. iter( ) ) ;
889893 let mut i = 0 ;
890- for it. advance |& x: & uint | {
894+ for it. advance |& x| {
891895 assert_eq ! ( x, expected[ i] ) ;
892896 i += 1 ;
893897 }
@@ -896,7 +900,7 @@ mod tests {
896900 let ys = Counter :: new( 30 u, 10 ) . take( 4 ) ;
897901 let mut it = xs. iter( ) . transform( |& x| x) . chain( ys) ;
898902 let mut i = 0 ;
899- for it. advance |x: uint | {
903+ for it. advance |x| {
900904 assert_eq ! ( x, expected[ i] ) ;
901905 i += 1 ;
902906 }
@@ -906,15 +910,15 @@ mod tests {
906910 #[ test]
907911 fn test_filter_map( ) {
908912 let mut it = Counter : : new( 0 u, 1 u) . take( 10 )
909- . filter_map( |x: uint | if x. is_even( ) { Some ( x* x) } else { None } ) ;
913+ . filter_map( |x| if x. is_even( ) { Some ( x* x) } else { None } ) ;
910914 assert_eq ! ( it. collect:: <~[ uint] >( ) , ~[ 0 * 0 , 2 * 2 , 4 * 4 , 6 * 6 , 8 * 8 ] ) ;
911915 }
912916
913917 #[ test]
914918 fn test_iterator_enumerate( ) {
915919 let xs = [ 0 u, 1 , 2 , 3 , 4 , 5 ] ;
916920 let mut it = xs. iter( ) . enumerate( ) ;
917- for it. advance |( i, & x) : ( uint , & uint ) | {
921+ for it. advance |( i, & x) | {
918922 assert_eq ! ( i, x) ;
919923 }
920924 }
@@ -925,7 +929,7 @@ mod tests {
925929 let ys = [ 0 u, 1 , 2 , 3 , 5 , 13 ] ;
926930 let mut it = xs. iter( ) . take_while( |& x| * x < 15 u) ;
927931 let mut i = 0 ;
928- for it. advance |& x: & uint | {
932+ for it. advance |& x| {
929933 assert_eq ! ( x, ys[ i] ) ;
930934 i += 1 ;
931935 }
@@ -938,7 +942,7 @@ mod tests {
938942 let ys = [ 15 , 16 , 17 , 19 ] ;
939943 let mut it = xs. iter( ) . skip_while( |& x| * x < 15 u) ;
940944 let mut i = 0 ;
941- for it. advance |& x: & uint | {
945+ for it. advance |& x| {
942946 assert_eq ! ( x, ys[ i] ) ;
943947 i += 1 ;
944948 }
@@ -1022,8 +1026,8 @@ mod tests {
10221026 #[ test]
10231027 fn test_iterator_last( ) {
10241028 let v = & [ 0 , 1 , 2 , 3 , 4 ] ;
1025- assert_eq ! ( v. iter( ) . last ( ) . unwrap( ) , & 4 ) ;
1026- assert_eq ! ( v. slice( 0 , 1 ) . iter( ) . last ( ) . unwrap( ) , & 0 ) ;
1029+ assert_eq ! ( v. iter( ) . last_ ( ) . unwrap( ) , & 4 ) ;
1030+ assert_eq ! ( v. slice( 0 , 1 ) . iter( ) . last_ ( ) . unwrap( ) , & 0 ) ;
10271031 }
10281032
10291033 #[ test]
0 commit comments