@@ -477,14 +477,13 @@ impl Regex {
477477 ( & self , text : & str , limit : uint , mut rep : R ) -> StrBuf {
478478 let mut new = StrBuf :: with_capacity ( text. len ( ) ) ;
479479 let mut last_match = 0 u;
480- let mut i = 0 ;
481- for cap in self . captures_iter ( text) {
480+
481+ for ( i , cap) in self . captures_iter ( text) . enumerate ( ) {
482482 // It'd be nicer to use the 'take' iterator instead, but it seemed
483483 // awkward given that '0' => no limit.
484484 if limit > 0 && i >= limit {
485485 break
486486 }
487- i += 1 ;
488487
489488 let ( s, e) = cap. pos ( 0 ) . unwrap ( ) ; // captures only reports matches
490489 new. push_str ( text. slice ( last_match, s) ) ;
@@ -800,7 +799,7 @@ impl<'r, 't> Iterator<Captures<'t>> for FindCaptures<'r, 't> {
800799
801800 // Don't accept empty matches immediately following a match.
802801 // i.e., no infinite loops please.
803- if e - s == 0 && Some ( self . last_end ) == self . last_match {
802+ if e == s && Some ( self . last_end ) == self . last_match {
804803 self . last_end += 1 ;
805804 return self . next ( )
806805 }
@@ -842,7 +841,7 @@ impl<'r, 't> Iterator<(uint, uint)> for FindMatches<'r, 't> {
842841
843842 // Don't accept empty matches immediately following a match.
844843 // i.e., no infinite loops please.
845- if e - s == 0 && Some ( self . last_end ) == self . last_match {
844+ if e == s && Some ( self . last_end ) == self . last_match {
846845 self . last_end += 1 ;
847846 return self . next ( )
848847 }
0 commit comments