11use std:: borrow:: Cow ;
22use std:: collections:: HashMap ;
33use std:: fmt;
4+ use std:: iter:: FusedIterator ;
45use std:: ops:: { Index , Range } ;
56use std:: str:: FromStr ;
67use std:: sync:: Arc ;
@@ -762,8 +763,16 @@ impl<'r> Iterator for CaptureNames<'r> {
762763 fn size_hint ( & self ) -> ( usize , Option < usize > ) {
763764 self . 0 . size_hint ( )
764765 }
766+
767+ fn count ( self ) -> usize {
768+ self . 0 . count ( )
769+ }
765770}
766771
772+ impl < ' r > ExactSizeIterator for CaptureNames < ' r > { }
773+
774+ impl < ' r > FusedIterator for CaptureNames < ' r > { }
775+
767776/// Yields all substrings delimited by a regular expression match.
768777///
769778/// `'r` is the lifetime of the compiled regular expression and `'t` is the
@@ -797,6 +806,8 @@ impl<'r, 't> Iterator for Split<'r, 't> {
797806 }
798807}
799808
809+ impl < ' r , ' t > FusedIterator for Split < ' r , ' t > { }
810+
800811/// Yields at most `N` substrings delimited by a regular expression match.
801812///
802813/// The last substring will be whatever remains after splitting.
@@ -830,8 +841,14 @@ impl<'r, 't> Iterator for SplitN<'r, 't> {
830841 Some ( & text[ self . splits . last ..] )
831842 }
832843 }
844+
845+ fn size_hint ( & self ) -> ( usize , Option < usize > ) {
846+ ( 0 , Some ( self . n ) )
847+ }
833848}
834849
850+ impl < ' r , ' t > FusedIterator for SplitN < ' r , ' t > { }
851+
835852/// CaptureLocations is a low level representation of the raw offsets of each
836853/// submatch.
837854///
@@ -1075,6 +1092,8 @@ impl<'c, 't> Iterator for SubCaptureMatches<'c, 't> {
10751092 }
10761093}
10771094
1095+ impl < ' c , ' t > FusedIterator for SubCaptureMatches < ' c , ' t > { }
1096+
10781097/// An iterator that yields all non-overlapping capture groups matching a
10791098/// particular regular expression.
10801099///
@@ -1098,6 +1117,8 @@ impl<'r, 't> Iterator for CaptureMatches<'r, 't> {
10981117 }
10991118}
11001119
1120+ impl < ' r , ' t > FusedIterator for CaptureMatches < ' r , ' t > { }
1121+
11011122/// An iterator over all non-overlapping matches for a particular string.
11021123///
11031124/// The iterator yields a `Match` value. The iterator stops when no more
@@ -1116,6 +1137,8 @@ impl<'r, 't> Iterator for Matches<'r, 't> {
11161137 }
11171138}
11181139
1140+ impl < ' r , ' t > FusedIterator for Matches < ' r , ' t > { }
1141+
11191142/// Replacer describes types that can be used to replace matches in a string.
11201143///
11211144/// In general, users of this crate shouldn't need to implement this trait,
0 commit comments