@@ -821,12 +821,14 @@ impl NamedGroups {
821
821
match * regex {
822
822
Regex :: Native ( ExNative { ref groups, .. } ) =>
823
823
NamedGroups :: Native ( groups) ,
824
- Regex :: Dynamic ( ref exec) =>
825
- if exec. named_groups ( ) . is_empty ( ) {
824
+ Regex :: Dynamic ( ref exec) => {
825
+ let groups = exec. named_groups ( ) ;
826
+ if groups. is_empty ( ) {
826
827
NamedGroups :: Empty
827
828
} else {
828
- NamedGroups :: Dynamic ( exec . named_groups ( ) . clone ( ) )
829
+ NamedGroups :: Dynamic ( groups . clone ( ) )
829
830
}
831
+ }
830
832
}
831
833
}
832
834
@@ -924,21 +926,21 @@ impl<'t> Captures<'t> {
924
926
925
927
/// Creates an iterator of all the capture groups in order of appearance
926
928
/// in the regular expression.
927
- pub fn iter < ' c > ( & ' c self ) -> SubCaptures < ' c , ' t > {
929
+ pub fn iter ( & ' t self ) -> SubCaptures < ' t > {
928
930
SubCaptures { idx : 0 , caps : self , }
929
931
}
930
932
931
933
/// Creates an iterator of all the capture group positions in order of
932
934
/// appearance in the regular expression. Positions are byte indices
933
935
/// in terms of the original string matched.
934
- pub fn iter_pos < ' c > ( & ' c self ) -> SubCapturesPos < ' c > {
936
+ pub fn iter_pos ( & ' t self ) -> SubCapturesPos < ' t > {
935
937
SubCapturesPos { idx : 0 , locs : & self . locs }
936
938
}
937
939
938
940
/// Creates an iterator of all named groups as an tuple with the group
939
941
/// name and the value. The iterator returns these values in arbitrary
940
942
/// order.
941
- pub fn iter_named < ' c : ' t > ( & ' c self ) -> SubCapturesNamed < ' c , ' t > {
943
+ pub fn iter_named ( & ' t self ) -> SubCapturesNamed < ' t > {
942
944
SubCapturesNamed {
943
945
caps : self ,
944
946
names : self . named_groups . iter ( )
@@ -1015,17 +1017,16 @@ impl<'t> Index<&'t str> for Captures<'t> {
1015
1017
/// An iterator over capture groups for a particular match of a regular
1016
1018
/// expression.
1017
1019
///
1018
- /// `'t` is the lifetime of the matched text.
1019
1020
/// `'c` is the lifetime of the captures.
1020
- pub struct SubCaptures < ' c , ' t : ' c > {
1021
+ pub struct SubCaptures < ' c > {
1021
1022
idx : usize ,
1022
- caps : & ' c Captures < ' t > ,
1023
+ caps : & ' c Captures < ' c > ,
1023
1024
}
1024
1025
1025
- impl < ' c , ' t > Iterator for SubCaptures < ' c , ' t > {
1026
- type Item = Option < & ' t str > ;
1026
+ impl < ' c > Iterator for SubCaptures < ' c > {
1027
+ type Item = Option < & ' c str > ;
1027
1028
1028
- fn next ( & mut self ) -> Option < Option < & ' t str > > {
1029
+ fn next ( & mut self ) -> Option < Option < & ' c str > > {
1029
1030
if self . idx < self . caps . len ( ) {
1030
1031
self . idx += 1 ;
1031
1032
Some ( self . caps . at ( self . idx - 1 ) )
@@ -1066,17 +1067,16 @@ impl<'c> Iterator for SubCapturesPos<'c> {
1066
1067
/// An Iterator over named capture groups as a tuple with the group
1067
1068
/// name and the value.
1068
1069
///
1069
- /// `'t` is the lifetime of the matched text.
1070
1070
/// `'c` is the lifetime of the captures.
1071
- pub struct SubCapturesNamed < ' c , ' t : ' c > {
1072
- caps : & ' c Captures < ' t > ,
1071
+ pub struct SubCapturesNamed < ' c > {
1072
+ caps : & ' c Captures < ' c > ,
1073
1073
names : NamedGroupsIter < ' c > ,
1074
1074
}
1075
1075
1076
- impl < ' c , ' t : ' c > Iterator for SubCapturesNamed < ' c , ' t > {
1077
- type Item = ( & ' c str , Option < & ' t str > ) ;
1076
+ impl < ' c > Iterator for SubCapturesNamed < ' c > {
1077
+ type Item = ( & ' c str , Option < & ' c str > ) ;
1078
1078
1079
- fn next ( & mut self ) -> Option < ( & ' c str , Option < & ' t str > ) > {
1079
+ fn next ( & mut self ) -> Option < ( & ' c str , Option < & ' c str > ) > {
1080
1080
self . names . next ( ) . map ( |( name, pos) | ( name, self . caps . at ( pos) ) )
1081
1081
}
1082
1082
}
0 commit comments