core: Rename vec::position_elt to position_elem

This commit is contained in:
Brian Anderson 2012-03-18 17:14:43 -07:00
parent cab02145ba
commit 13bcc73625
4 changed files with 15 additions and 14 deletions

View file

@ -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

View file

@ -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<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 }
}
@ -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 }
}
@ -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]

View file

@ -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);

View file

@ -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"; }
}