diff --git a/doc/tutorial.md b/doc/tutorial.md index a6102123711..1116e682af9 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -921,8 +921,8 @@ for the parameter list, as in `{|| ...}`. Partial application is done using the `bind` keyword in Rust. ~~~~ -let daynum = bind vec::position_elt(["mo", "tu", "we", "do", - "fr", "sa", "su"], _); +let daynum = bind vec::position_elem(["mo", "tu", "we", "do", + "fr", "sa", "su"], _); ~~~~ Binding a function produces a boxed closure (`fn@` type) in which some diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index 1fe3ac22ceb..a24ea84b518 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -50,10 +50,10 @@ export find; export find_from; export rfind; export rfind_from; -export position_elt; +export position_elem; export position; export position_from; -export position_elt; +export position_elem; export rposition; export rposition_from; export unzip; @@ -613,7 +613,7 @@ fn rfind_from(v: [const T], start: uint, end: uint, } #[doc = "Find the first index containing a matching value"] -fn position_elt(v: [const T], x: T) -> option { +fn position_elem(v: [const T], x: T) -> option { position(v) { |y| x == y } } @@ -645,7 +645,7 @@ fn position_from(v: [const T], start: uint, end: uint, } #[doc = "Find the last index containing a matching value"] -fn rposition_elt(v: [const T], x: T) -> option { +fn rposition_elem(v: [const T], x: T) -> option { rposition(v) { |y| x == y } } @@ -1439,14 +1439,14 @@ mod tests { } #[test] - fn test_position_elt() { - assert position_elt([], 1) == none; + fn test_position_elem() { + assert position_elem([], 1) == none; let v1 = [1, 2, 3, 3, 2, 5]; - assert position_elt(v1, 1) == some(0u); - assert position_elt(v1, 2) == some(1u); - assert position_elt(v1, 5) == some(5u); - assert position_elt(v1, 4) == none; + assert position_elem(v1, 1) == some(0u); + assert position_elem(v1, 2) == some(1u); + assert position_elem(v1, 5) == some(5u); + assert position_elem(v1, 4) == none; } #[test] diff --git a/src/rustc/middle/kind.rs b/src/rustc/middle/kind.rs index e33389c29b8..b85627c6856 100644 --- a/src/rustc/middle/kind.rs +++ b/src/rustc/middle/kind.rs @@ -91,7 +91,8 @@ fn check_fn(fk: visit::fn_kind, decl: fn_decl, body: blk, sp: span, some(last_use::closes_over(vars)) { vars } none { [] } }; - if option::is_some(vec::position_elt(last_uses, id)) { cont; } + if option::is_some( + vec::position_elem(last_uses, id)) { cont; } } let ty = ty::node_id_to_type(cx.tcx, id); checker(cx, ty, span); diff --git a/src/rustc/middle/trans/shape.rs b/src/rustc/middle/trans/shape.rs index 88860e2aeab..2029b86b974 100644 --- a/src/rustc/middle/trans/shape.rs +++ b/src/rustc/middle/trans/shape.rs @@ -393,7 +393,7 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t, ty_param_map: [uint]) -> [u8] { } ty::ty_param(n, _) { // Find the type parameter in the parameter list. - alt vec::position_elt(ty_param_map, n) { + alt vec::position_elem(ty_param_map, n) { some(i) { [shape_var, i as u8] } none { fail "ty param not found in ty_param_map"; } }