core: Rename vec::member to vec::contains to match str mod
This commit is contained in:
parent
737db5b49a
commit
1040b47078
src
@ -800,7 +800,7 @@ fn cmd_search(c: cargo) {
|
||||
let tags = vec::slice(c.opts.free, 3u, vec::len(c.opts.free));
|
||||
for_each_package(c, { |s, p|
|
||||
if (str::contains(p.name, name) || name == "*") &&
|
||||
vec::all(tags, { |t| vec::member(t, p.tags) }) {
|
||||
vec::all(tags, { |t| vec::contains(t, p.tags) }) {
|
||||
print_pkg(s, p);
|
||||
n += 1;
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ fn iter_crate_data(cstore: cstore, i: fn(ast::crate_num, crate_metadata)) {
|
||||
}
|
||||
|
||||
fn add_used_crate_file(cstore: cstore, lib: str) {
|
||||
if !vec::member(lib, p(cstore).used_crate_files) {
|
||||
if !vec::contains(lib, p(cstore).used_crate_files) {
|
||||
p(cstore).used_crate_files += [lib];
|
||||
}
|
||||
}
|
||||
@ -109,7 +109,7 @@ fn get_used_crate_files(cstore: cstore) -> [str] {
|
||||
fn add_used_library(cstore: cstore, lib: str) -> bool {
|
||||
assert lib != "";
|
||||
|
||||
if vec::member(lib, p(cstore).used_libraries) { ret false; }
|
||||
if vec::contains(lib, p(cstore).used_libraries) { ret false; }
|
||||
p(cstore).used_libraries += [lib];
|
||||
ret true;
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ fn check_exhaustive(tcx: ty::ctxt, sp:span, scrut_ty:ty::t, pats:[@pat]) {
|
||||
}
|
||||
}
|
||||
fn not_represented(v: [def_id], &&vinfo: variant_info) -> bool {
|
||||
!vec::member(vinfo.id, v)
|
||||
!vec::contains(vinfo.id, v)
|
||||
}
|
||||
// Could be more efficient (bitvectors?)
|
||||
alt vec::find(variants, bind not_represented(represented,_)) {
|
||||
|
@ -109,7 +109,7 @@ fn check_fn_cap_clause(cx: ctx,
|
||||
let check_var = fn@(&&cap_item: @capture_item) {
|
||||
let cap_def = cx.tcx.def_map.get(cap_item.id);
|
||||
let cap_def_id = ast_util::def_id_of_def(cap_def).node;
|
||||
if !vec::member(cap_def_id, freevar_ids) {
|
||||
if !vec::contains(cap_def_id, freevar_ids) {
|
||||
let ty = ty::node_id_to_type(cx.tcx, cap_def_id);
|
||||
checker(cx, ty, cap_item.span);
|
||||
}
|
||||
|
@ -317,7 +317,7 @@ fn check_unused_imports(e: @env) {
|
||||
e.imports.items {|k, v|
|
||||
alt v {
|
||||
resolved(_, _, _, _, name, sp) {
|
||||
if !vec::member(k, e.used_imports.data) {
|
||||
if !vec::contains(k, e.used_imports.data) {
|
||||
e.sess.span_warn(sp, "unused import " + name);
|
||||
}
|
||||
}
|
||||
@ -1279,7 +1279,7 @@ fn found_view_item(e: env, id: node_id) -> def {
|
||||
|
||||
fn lookup_import(e: env, defid: def_id, ns: namespace) -> option<def> {
|
||||
// Imports are simply ignored when resolving themselves.
|
||||
if vec::member(defid.node, e.ignored_imports) { ret none; }
|
||||
if vec::contains(defid.node, e.ignored_imports) { ret none; }
|
||||
alt e.imports.get(defid.node) {
|
||||
todo(node_id, name, path, span, scopes) {
|
||||
resolve_import(e, local_def(node_id), name, *path, span, scopes);
|
||||
@ -1344,7 +1344,7 @@ fn lookup_in_globs(e: env, globs: [glob_imp_def], sp: span, id: ident,
|
||||
ns: namespace, dr: dir) -> option<glob_imp_def> {
|
||||
alt def.item.node {
|
||||
ast::view_item_import_glob(_, id) {
|
||||
if vec::member(id, e.ignored_imports) { ret none; }
|
||||
if vec::contains(id, e.ignored_imports) { ret none; }
|
||||
}
|
||||
_ {
|
||||
e.sess.span_bug(sp, "lookup_in_globs: not a glob");
|
||||
|
@ -1387,7 +1387,7 @@ fn occurs_check_fails(tcx: ctxt, sp: option<span>, vid: int, rt: t) ->
|
||||
if !type_has_vars(rt) { ret false; }
|
||||
|
||||
// Occurs check!
|
||||
if vec::member(vid, vars_in_type(tcx, rt)) {
|
||||
if vec::contains(vid, vars_in_type(tcx, rt)) {
|
||||
alt sp {
|
||||
some(s) {
|
||||
// Maybe this should be span_err -- however, there's an
|
||||
|
@ -2656,7 +2656,7 @@ fn check_enum_variants(ccx: @crate_ctxt, sp: span, vs: [ast::variant],
|
||||
}
|
||||
_ {}
|
||||
}
|
||||
if vec::member(disr_val, disr_vals) {
|
||||
if vec::contains(disr_val, disr_vals) {
|
||||
ccx.tcx.sess.span_err(v.span,
|
||||
"discriminator value already exists.");
|
||||
}
|
||||
|
@ -689,11 +689,11 @@ fn all2<T, U>(v0: [T], v1: [U], f: fn(T, U) -> bool) -> bool {
|
||||
}
|
||||
|
||||
/*
|
||||
Function: member
|
||||
Function: contains
|
||||
|
||||
Return true if a vector contains an element with the given value
|
||||
*/
|
||||
fn member<T>(x: T, v: [T]) -> bool {
|
||||
fn contains<T>(x: T, v: [T]) -> bool {
|
||||
for elt: T in v { if x == elt { ret true; } }
|
||||
ret false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user