@@ -13,24 +13,31 @@ use syntax::ast;
13
13
use syntax:: print:: pp;
14
14
use syntax:: print:: pprust;
15
15
use syntax:: parse:: token;
16
+ use syntax:: visit;
16
17
17
- pub fn each_binding ( l : @ast:: Local , f : @fn ( & ast:: Path , ast:: NodeId ) ) {
18
- use syntax:: oldvisit;
18
+ struct EachBindingVisitor {
19
+ f : @fn ( & ast:: Path , ast:: NodeId )
20
+ }
19
21
20
- let vt = oldvisit:: mk_simple_visitor (
21
- @oldvisit:: SimpleVisitor {
22
- visit_pat : |pat| {
22
+ impl visit:: Visitor < ( ) > for EachBindingVisitor {
23
+ fn visit_pat ( & mut self , pat : @ast:: pat , _: ( ) ) {
23
24
match pat. node {
24
25
ast:: pat_ident( _, ref path, _) => {
25
- f ( path, pat. id ) ;
26
+ ( self . f ) ( path, pat. id ) ;
26
27
}
27
28
_ => { }
28
29
}
29
- } ,
30
- .. * oldvisit:: default_simple_visitor ( )
31
- }
32
- ) ;
33
- ( vt. visit_pat ) ( l. pat , ( ( ) , vt) ) ;
30
+
31
+ visit:: walk_pat ( self , pat, ( ) ) ;
32
+ }
33
+ }
34
+
35
+ pub fn each_binding ( l : @ast:: Local , f : @fn ( & ast:: Path , ast:: NodeId ) ) {
36
+ use syntax:: visit:: Visitor ;
37
+
38
+ let mut vt = EachBindingVisitor { f : f } ;
39
+
40
+ vt. visit_pat ( l. pat , ( ) ) ;
34
41
}
35
42
36
43
/// A utility function that hands off a pretty printer to a callback.
0 commit comments