about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorLuqman Aden <laden@csclub.uwaterloo.ca>2014-06-12 06:13:25 -0400
committerLuqman Aden <me@luqman.ca>2014-07-09 15:51:58 -0700
commit9e123c40568f5ca79a0826fe2b45933fb0d36eaf (patch)
treed438f1482ecb3ef1890240e26b25990d310ad58c /src/libsyntax
parentbb9552ef00a986a6aed947b0399a1b620b74e096 (diff)
downloadrust-9e123c40568f5ca79a0826fe2b45933fb0d36eaf.tar.gz
rust-9e123c40568f5ca79a0826fe2b45933fb0d36eaf.zip
libsyntax: Remove uses of advance.
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/abi.rs17
-rw-r--r--src/libsyntax/ast_util.rs10
2 files changed, 6 insertions, 21 deletions
diff --git a/src/libsyntax/abi.rs b/src/libsyntax/abi.rs
index 5aaf7ed3dba..8b01002831b 100644
--- a/src/libsyntax/abi.rs
+++ b/src/libsyntax/abi.rs
@@ -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> {
diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs
index 13fe8a15064..cd38c9b3e98 100644
--- a/src/libsyntax/ast_util.rs
+++ b/src/libsyntax/ast_util.rs
@@ -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(_, _, _) |