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 55use nfa:: NFA ;
66use nfa:: CharacterClass ;
77use std:: collections:: BTreeMap ;
8+ use std:: collections:: btree_map;
89use std:: cmp:: Ordering ;
910use std:: ops:: Index ;
1011
@@ -75,6 +76,10 @@ impl Params {
7576 pub fn find ( & self , key : & str ) -> Option < & str > {
7677 self . map . get ( key) . map ( |s| & s[ ..] )
7778 }
79+
80+ pub fn iter < ' a > ( & ' a self ) -> Iter < ' a > {
81+ Iter ( self . map . iter ( ) )
82+ }
7883}
7984
8085impl < ' a > Index < & ' a str > for Params {
@@ -87,6 +92,30 @@ impl<'a> Index<&'a str> for Params {
8792 }
8893}
8994
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+
90119pub struct Match < T > {
91120 pub handler : T ,
92121 pub params : Params
You can’t perform that action at this time.
0 commit comments