about summary refs log tree commit diff
path: root/src/libsyntax/ast_util.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-06-01 19:22:42 -0700
committerbors <bors@rust-lang.org>2013-06-01 19:22:42 -0700
commitfc5debd8fdda339e1453dc43368f4bfb15459841 (patch)
treea445c8ab39274ce9520ff898a6b71f3702a09b59 /src/libsyntax/ast_util.rs
parent63417daea4058646ef07a880edc79653ddc16bbf (diff)
parent60126e9365e86f9697508455290850564ac9186e (diff)
downloadrust-fc5debd8fdda339e1453dc43368f4bfb15459841.tar.gz
rust-fc5debd8fdda339e1453dc43368f4bfb15459841.zip
auto merge of #6807 : catamorphism/rust/rustpkg-extern-mod, r=catamorphism
r? @graydon Addresses #5681
Diffstat (limited to 'src/libsyntax/ast_util.rs')
-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) |