about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ast_util.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs
index eab8c0a12d3..95dce88d450 100644
--- a/src/libsyntax/ast_util.rs
+++ b/src/libsyntax/ast_util.rs
@@ -562,6 +562,21 @@ pub fn walk_pat(pat: @pat, it: &fn(@pat) -> bool) -> bool {
     }
 }
 
+pub trait EachViewItem {
+    pub fn each_view_item(&self, f: @fn(@ast::view_item) -> bool) -> bool;
+}
+
+impl EachViewItem for ast::crate {
+    fn each_view_item(&self, f: @fn(@ast::view_item) -> bool) -> bool {
+        let broke = @mut false;
+        let vtor: visit::vt<()> = visit::mk_simple_visitor(@visit::SimpleVisitor {
+            visit_view_item: |vi| { *broke = f(vi); }, ..*visit::default_simple_visitor()
+        });
+        visit::visit_crate(self, (), vtor);
+        true
+    }
+}
+
 pub fn view_path_id(p: @view_path) -> node_id {
     match p.node {
       view_path_simple(_, _, id) |