Skip to content

Commit

Permalink
core: Rename vec::position_elt to position_elem
Browse files Browse the repository at this point in the history
  • Loading branch information
brson committed Mar 19, 2012
1 parent cab0214 commit 13bcc73
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
4 changes: 2 additions & 2 deletions doc/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions src/libcore/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -613,7 +613,7 @@ fn rfind_from<T: copy>(v: [const T], start: uint, end: uint,
}

#[doc = "Find the first index containing a matching value"]
fn position_elt<T>(v: [const T], x: T) -> option<uint> {
fn position_elem<T>(v: [const T], x: T) -> option<uint> {
position(v) { |y| x == y }
}

Expand Down Expand Up @@ -645,7 +645,7 @@ fn position_from<T>(v: [const T], start: uint, end: uint,
}

#[doc = "Find the last index containing a matching value"]
fn rposition_elt<T>(v: [const T], x: T) -> option<uint> {
fn rposition_elem<T>(v: [const T], x: T) -> option<uint> {
rposition(v) { |y| x == y }
}

Expand Down Expand Up @@ -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]
Expand Down
3 changes: 2 additions & 1 deletion src/rustc/middle/kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/rustc/middle/trans/shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"; }
}
Expand Down

0 comments on commit 13bcc73

Please sign in to comment.