File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 5
5
use nfa:: NFA ;
6
6
use nfa:: CharacterClass ;
7
7
use std:: collections:: BTreeMap ;
8
+ use std:: collections:: btree_map;
8
9
use std:: cmp:: Ordering ;
9
10
use std:: ops:: Index ;
10
11
@@ -75,6 +76,10 @@ impl Params {
75
76
pub fn find ( & self , key : & str ) -> Option < & str > {
76
77
self . map . get ( key) . map ( |s| & s[ ..] )
77
78
}
79
+
80
+ pub fn iter < ' a > ( & ' a self ) -> Iter < ' a > {
81
+ Iter ( self . map . iter ( ) )
82
+ }
78
83
}
79
84
80
85
impl < ' a > Index < & ' a str > for Params {
@@ -87,6 +92,30 @@ impl<'a> Index<&'a str> for Params {
87
92
}
88
93
}
89
94
95
+ impl < ' a > IntoIterator for & ' a Params {
96
+ type IntoIter = Iter < ' a > ;
97
+ type Item = ( & ' a str , & ' a str ) ;
98
+
99
+ fn into_iter ( self ) -> Iter < ' a > {
100
+ self . iter ( )
101
+ }
102
+ }
103
+
104
+ pub struct Iter < ' a > ( btree_map:: Iter < ' a , String , String > ) ;
105
+
106
+ impl < ' a > Iterator for Iter < ' a > {
107
+ type Item = ( & ' a str , & ' a str ) ;
108
+
109
+ #[ inline]
110
+ fn next ( & mut self ) -> Option < ( & ' a str , & ' a str ) > {
111
+ self . 0 . next ( ) . map ( |( k, v) | ( & * * k, & * * v) )
112
+ }
113
+
114
+ fn size_hint ( & self ) -> ( usize , Option < usize > ) {
115
+ self . 0 . size_hint ( )
116
+ }
117
+ }
118
+
90
119
pub struct Match < T > {
91
120
pub handler : T ,
92
121
pub params : Params
You can’t perform that action at this time.
0 commit comments