1
1
use std:: borrow:: Cow ;
2
2
use std:: collections:: HashMap ;
3
3
use std:: fmt;
4
+ use std:: iter:: FusedIterator ;
4
5
use std:: ops:: { Index , Range } ;
5
6
use std:: str:: FromStr ;
6
7
use std:: sync:: Arc ;
@@ -762,8 +763,16 @@ impl<'r> Iterator for CaptureNames<'r> {
762
763
fn size_hint ( & self ) -> ( usize , Option < usize > ) {
763
764
self . 0 . size_hint ( )
764
765
}
766
+
767
+ fn count ( self ) -> usize {
768
+ self . 0 . count ( )
769
+ }
765
770
}
766
771
772
+ impl < ' r > ExactSizeIterator for CaptureNames < ' r > { }
773
+
774
+ impl < ' r > FusedIterator for CaptureNames < ' r > { }
775
+
767
776
/// Yields all substrings delimited by a regular expression match.
768
777
///
769
778
/// `'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> {
797
806
}
798
807
}
799
808
809
+ impl < ' r , ' t > FusedIterator for Split < ' r , ' t > { }
810
+
800
811
/// Yields at most `N` substrings delimited by a regular expression match.
801
812
///
802
813
/// The last substring will be whatever remains after splitting.
@@ -830,8 +841,14 @@ impl<'r, 't> Iterator for SplitN<'r, 't> {
830
841
Some ( & text[ self . splits . last ..] )
831
842
}
832
843
}
844
+
845
+ fn size_hint ( & self ) -> ( usize , Option < usize > ) {
846
+ ( 0 , Some ( self . n ) )
847
+ }
833
848
}
834
849
850
+ impl < ' r , ' t > FusedIterator for SplitN < ' r , ' t > { }
851
+
835
852
/// CaptureLocations is a low level representation of the raw offsets of each
836
853
/// submatch.
837
854
///
@@ -1075,6 +1092,8 @@ impl<'c, 't> Iterator for SubCaptureMatches<'c, 't> {
1075
1092
}
1076
1093
}
1077
1094
1095
+ impl < ' c , ' t > FusedIterator for SubCaptureMatches < ' c , ' t > { }
1096
+
1078
1097
/// An iterator that yields all non-overlapping capture groups matching a
1079
1098
/// particular regular expression.
1080
1099
///
@@ -1098,6 +1117,8 @@ impl<'r, 't> Iterator for CaptureMatches<'r, 't> {
1098
1117
}
1099
1118
}
1100
1119
1120
+ impl < ' r , ' t > FusedIterator for CaptureMatches < ' r , ' t > { }
1121
+
1101
1122
/// An iterator over all non-overlapping matches for a particular string.
1102
1123
///
1103
1124
/// The iterator yields a `Match` value. The iterator stops when no more
@@ -1116,6 +1137,8 @@ impl<'r, 't> Iterator for Matches<'r, 't> {
1116
1137
}
1117
1138
}
1118
1139
1140
+ impl < ' r , ' t > FusedIterator for Matches < ' r , ' t > { }
1141
+
1119
1142
/// Replacer describes types that can be used to replace matches in a string.
1120
1143
///
1121
1144
/// In general, users of this crate shouldn't need to implement this trait,
0 commit comments