Skip to content

Commit

Permalink
libsyntax: Remove uses of advance.
Browse files Browse the repository at this point in the history
  • Loading branch information
luqmana committed Jul 9, 2014
1 parent bb9552e commit 9e123c4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 21 deletions.
17 changes: 1 addition & 16 deletions src/libsyntax/abi.rs
Expand Up @@ -87,24 +87,9 @@ static AbiDatas: &'static [AbiData] = &[
AbiData {abi: RustIntrinsic, name: "rust-intrinsic", abi_arch: RustArch},
];

/// Iterates through each of the defined ABIs.
fn each_abi(op: |abi: Abi| -> bool) -> bool {
AbiDatas.iter().advance(|abi_data| op(abi_data.abi))
}

/// Returns the ABI with the given name (if any).
pub fn lookup(name: &str) -> Option<Abi> {
let mut res = None;

each_abi(|abi| {
if name == abi.data().name {
res = Some(abi);
false
} else {
true
}
});
res
AbiDatas.iter().find(|abi_data| name == abi_data.name).map(|&x| x.abi)
}

pub fn all_names() -> Vec<&'static str> {
Expand Down
10 changes: 5 additions & 5 deletions src/libsyntax/ast_util.rs
Expand Up @@ -611,18 +611,18 @@ pub fn walk_pat(pat: &Pat, it: |&Pat| -> bool) -> bool {
match pat.node {
PatIdent(_, _, Some(ref p)) => walk_pat(&**p, it),
PatStruct(_, ref fields, _) => {
fields.iter().advance(|f| walk_pat(&*f.pat, |p| it(p)))
fields.iter().all(|field| walk_pat(&*field.pat, |p| it(p)))
}
PatEnum(_, Some(ref s)) | PatTup(ref s) => {
s.iter().advance(|p| walk_pat(&**p, |p| it(p)))
s.iter().all(|p| walk_pat(&**p, |p| it(p)))
}
PatBox(ref s) | PatRegion(ref s) => {
walk_pat(&**s, it)
}
PatVec(ref before, ref slice, ref after) => {
before.iter().advance(|p| walk_pat(&**p, |p| it(p))) &&
slice.iter().advance(|p| walk_pat(&**p, |p| it(p))) &&
after.iter().advance(|p| walk_pat(&**p, |p| it(p)))
before.iter().all(|p| walk_pat(&**p, |p| it(p))) &&
slice.iter().all(|p| walk_pat(&**p, |p| it(p))) &&
after.iter().all(|p| walk_pat(&**p, |p| it(p)))
}
PatMac(_) => fail!("attempted to analyze unexpanded pattern"),
PatWild | PatWildMulti | PatLit(_) | PatRange(_, _) | PatIdent(_, _, _) |
Expand Down

0 comments on commit 9e123c4

Please sign in to comment.