syntax: Add an each_view_item method on traits
This commit is contained in:
parent
231aea6d6e
commit
760c71dc4f
@ -560,6 +560,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) |
|
||||
|
Loading…
x
Reference in New Issue
Block a user