about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc/middle/check_match.rs2
-rw-r--r--src/librustc/middle/trans/monomorphize.rs2
-rw-r--r--src/librustc/middle/ty.rs5
-rw-r--r--src/librustc/middle/typeck/check/mod.rs2
-rw-r--r--src/librustdoc/attr_pass.rs2
-rw-r--r--src/librustdoc/config.rs9
-rw-r--r--src/librustdoc/tystr_pass.rs8
-rw-r--r--src/libstd/str.rs2
-rw-r--r--src/libstd/vec.rs41
9 files changed, 16 insertions, 57 deletions
diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs
index 4da88981a63..346e2162385 100644
--- a/src/librustc/middle/check_match.rs
+++ b/src/librustc/middle/check_match.rs
@@ -456,7 +456,7 @@ pub fn ctor_arity(cx: @MatchCheckCtxt, ctor: &ctor, ty: ty::t) -> uint {
       ty::ty_enum(eid, _) => {
           let id = match *ctor { variant(id) => id,
           _ => fail!("impossible case") };
-        match vec::find(*ty::enum_variants(cx.tcx, eid), |v| v.id == id ) {
+        match ty::enum_variants(cx.tcx, eid).iter().find_(|v| v.id == id ) {
             Some(v) => v.args.len(),
             None => fail!("impossible case")
         }
diff --git a/src/librustc/middle/trans/monomorphize.rs b/src/librustc/middle/trans/monomorphize.rs
index 368ad0674e1..f082150e394 100644
--- a/src/librustc/middle/trans/monomorphize.rs
+++ b/src/librustc/middle/trans/monomorphize.rs
@@ -209,7 +209,7 @@ pub fn monomorphic_fn(ccx: @mut CrateContext,
       }
       ast_map::node_variant(ref v, enum_item, _) => {
         let tvs = ty::enum_variants(ccx.tcx, local_def(enum_item.id));
-        let this_tv = vec::find(*tvs, |tv| { tv.id.node == fn_id.node}).get();
+        let this_tv = *tvs.iter().find_(|tv| { tv.id.node == fn_id.node}).get();
         let d = mk_lldecl();
         set_inline_hint(d);
         match v.node.kind {
diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs
index 2340ffc76b3..8595adcd1c7 100644
--- a/src/librustc/middle/ty.rs
+++ b/src/librustc/middle/ty.rs
@@ -4128,9 +4128,10 @@ pub fn lookup_struct_field(cx: ctxt,
                            parent: ast::def_id,
                            field_id: ast::def_id)
                         -> field_ty {
-    match vec::find(lookup_struct_fields(cx, parent),
+    let r = lookup_struct_fields(cx, parent);
+    match r.iter().find_(
                  |f| f.id.node == field_id.node) {
-        Some(t) => t,
+        Some(t) => *t,
         None => cx.sess.bug("struct ID not found in parent's fields")
     }
 }
diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs
index 2d8233f8c0a..13ded501679 100644
--- a/src/librustc/middle/typeck/check/mod.rs
+++ b/src/librustc/middle/typeck/check/mod.rs
@@ -1107,7 +1107,7 @@ pub fn lookup_field_ty(tcx: ty::ctxt,
                        fieldname: ast::ident,
                        substs: &ty::substs) -> Option<ty::t> {
 
-    let o_field = vec::find(items, |f| f.ident == fieldname);
+    let o_field = items.iter().find_(|f| f.ident == fieldname);
     do o_field.map() |f| {
         ty::lookup_field_type(tcx, class_id, f.id, substs)
     }
diff --git a/src/librustdoc/attr_pass.rs b/src/librustdoc/attr_pass.rs
index a1dad7d17f8..1c34007c99d 100644
--- a/src/librustdoc/attr_pass.rs
+++ b/src/librustdoc/attr_pass.rs
@@ -135,7 +135,7 @@ fn fold_enum(
                             node: ast::item_enum(ref enum_definition, _), _
                         }, _) => {
                             let ast_variant =
-                                vec::find(enum_definition.variants, |v| {
+                                copy *enum_definition.variants.iter().find_(|v| {
                                     to_str(v.node.name) == variant.name
                                 }).get();
 
diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs
index ef65cc8e5a1..84a194627fb 100644
--- a/src/librustdoc/config.rs
+++ b/src/librustdoc/config.rs
@@ -230,16 +230,15 @@ pub fn maybe_find_pandoc(
       }
     };
 
-    let pandoc = do vec::find(possible_pandocs) |pandoc| {
+    let pandoc = do possible_pandocs.iter().find_ |&pandoc| {
         let output = process_output(*pandoc, [~"--version"]);
         debug!("testing pandoc cmd %s: %?", *pandoc, output);
         output.status == 0
     };
 
-    if pandoc.is_some() {
-        result::Ok(pandoc)
-    } else {
-        result::Err(~"couldn't find pandoc")
+    match pandoc {
+        Some(x) => Ok(Some(copy *x)), // ugly, shouldn't be doubly wrapped
+        None => Err(~"couldn't find pandoc")
     }
 }
 
diff --git a/src/librustdoc/tystr_pass.rs b/src/librustdoc/tystr_pass.rs
index 82336addb62..e3abe6e926a 100644
--- a/src/librustdoc/tystr_pass.rs
+++ b/src/librustdoc/tystr_pass.rs
@@ -124,7 +124,7 @@ fn fold_enum(
                             node: ast::item_enum(ref enum_definition, _), _
                         }, _) => {
                             let ast_variant =
-                                do vec::find(enum_definition.variants) |v| {
+                                copy *do enum_definition.variants.iter().find_ |v| {
                                 to_str(v.node.name) == variant.name
                             }.get();
 
@@ -178,14 +178,14 @@ fn get_method_sig(
             ast_map::node_item(@ast::item {
                 node: ast::item_trait(_, _, ref methods), _
             }, _) => {
-                match vec::find(*methods, |method| {
+                match methods.iter().find_(|&method| {
                     match copy *method {
                         ast::required(ty_m) => to_str(ty_m.ident) == method_name,
                         ast::provided(m) => to_str(m.ident) == method_name,
                     }
                 }) {
                     Some(method) => {
-                        match method {
+                        match copy *method {
                             ast::required(ty_m) => {
                                 Some(pprust::fun_to_str(
                                     &ty_m.decl,
@@ -214,7 +214,7 @@ fn get_method_sig(
             ast_map::node_item(@ast::item {
                 node: ast::item_impl(_, _, _, ref methods), _
             }, _) => {
-                match vec::find(*methods, |method| {
+                match methods.iter().find_(|method| {
                     to_str(method.ident) == method_name
                 }) {
                     Some(method) => {
diff --git a/src/libstd/str.rs b/src/libstd/str.rs
index fd11b49a00a..f3226b27d1b 100644
--- a/src/libstd/str.rs
+++ b/src/libstd/str.rs
@@ -60,7 +60,7 @@ pub fn from_bytes(vv: &[u8]) -> ~str {
     use str::not_utf8::cond;
 
     if !is_utf8(vv) {
-        let first_bad_byte = vec::find(vv, |b| !is_utf8([*b])).get();
+        let first_bad_byte = *vv.iter().find_(|&b| !is_utf8([*b])).get();
         cond.raise(fmt!("from_bytes: input is not UTF-8; first bad byte is %u",
                         first_bad_byte as uint))
     }
diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs
index ce5662c6d4b..703224e37c5 100644
--- a/src/libstd/vec.rs
+++ b/src/libstd/vec.rs
@@ -1057,17 +1057,6 @@ pub fn contains<T:Eq>(v: &[T], x: &T) -> bool {
 }
 
 /**
- * Search for the first element that matches a given predicate
- *
- * Apply function `f` to each element of `v`, starting from the first.
- * When function `f` returns true then an option containing the element
- * is returned. If `f` matches no elements then none is returned.
- */
-pub fn find<T:Copy>(v: &[T], f: &fn(t: &T) -> bool) -> Option<T> {
-    find_between(v, 0u, v.len(), f)
-}
-
-/**
  * Search for the first element that matches a given predicate within a range
  *
  * Apply function `f` to each element of `v` within the range
@@ -3164,18 +3153,6 @@ mod tests {
     }
 
     #[test]
-    fn test_find() {
-        assert!(find([], f).is_none());
-
-        fn f(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'b' }
-        fn g(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'd' }
-        let v = ~[(0, 'a'), (1, 'b'), (2, 'c'), (3, 'b')];
-
-        assert_eq!(find(v, f), Some((1, 'b')));
-        assert!(find(v, g).is_none());
-    }
-
-    #[test]
     fn test_find_between() {
         assert!(find_between([], 0u, 0u, f).is_none());
 
@@ -3205,8 +3182,6 @@ mod tests {
 
     #[test]
     fn test_rposition() {
-        assert!(find([], f).is_none());
-
         fn f(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'b' }
         fn g(xy: &(int, char)) -> bool { let (_x, y) = *xy; y == 'd' }
         let v = ~[(0, 'a'), (1, 'b'), (2, 'c'), (3, 'b')];
@@ -3841,22 +3816,6 @@ mod tests {
     #[test]
     #[ignore(windows)]
     #[should_fail]
-    #[allow(non_implicitly_copyable_typarams)]
-    fn test_find_fail() {
-        let v = [(~0, @0), (~0, @0), (~0, @0), (~0, @0)];
-        let mut i = 0;
-        do find(v) |_elt| {
-            if i == 2 {
-                fail!()
-            }
-            i += 0;
-            false
-        };
-    }
-
-    #[test]
-    #[ignore(windows)]
-    #[should_fail]
     fn test_rposition_fail() {
         let v = [(~0, @0), (~0, @0), (~0, @0), (~0, @0)];
         let mut i = 0;