core: rename vec.filter to vec.filtered

This commit is contained in:
Erick Tryzelaar 2013-01-07 21:15:25 -08:00
parent 9a7e261562
commit 2891a49f0d
12 changed files with 27 additions and 25 deletions

View File

@ -526,7 +526,7 @@ fn make_run_args(config: config, _props: test_props, testfile: &Path) ->
fn split_maybe_args(argstr: Option<~str>) -> ~[~str] {
fn rm_whitespace(v: ~[~str]) -> ~[~str] {
vec::filter(v, |s| !str::is_whitespace(*s))
v.filtered(|s| !str::is_whitespace(*s))
}
match argstr {

View File

@ -619,7 +619,7 @@ fn star(p: &Path) -> Path { copy *p }
#[cfg(windows)]
fn star(p: &Path) -> Path { p.push("*") }
do rustrt::rust_list_files2(star(p).to_str()).filter |filename| {
do rustrt::rust_list_files2(star(p).to_str()).filtered |filename| {
*filename != ~"." && *filename != ~".."
}
}

View File

@ -853,7 +853,7 @@ pub fn map_consume<T, U>(v: ~[T], f: fn(v: T) -> U) -> ~[U] {
* Apply function `f` to each element of `v` and return a vector containing
* only those elements for which `f` returned true.
*/
pub pure fn filter<T: Copy>(v: &[T], f: fn(t: &T) -> bool) -> ~[T] {
pub pure fn filtered<T: Copy>(v: &[T], f: fn(t: &T) -> bool) -> ~[T] {
let mut result = ~[];
for each(v) |elem| {
if f(elem) { unsafe { result.push(*elem); } }
@ -1752,7 +1752,7 @@ impl<T: Eq> &[T]: ImmutableEqVector<T> {
}
pub trait ImmutableCopyableVector<T> {
pure fn filter(&self, f: fn(t: &T) -> bool) -> ~[T];
pure fn filtered(&self, f: fn(&T) -> bool) -> ~[T];
pure fn rfind(&self, f: fn(t: &T) -> bool) -> Option<T>;
pure fn partitioned(&self, f: fn(&T) -> bool) -> (~[T], ~[T]);
}
@ -1767,8 +1767,8 @@ impl<T: Copy> &[T]: ImmutableCopyableVector<T> {
* containing only those elements for which `f` returned true.
*/
#[inline]
pure fn filter(&self, f: fn(t: &T) -> bool) -> ~[T] {
filter(*self, f)
pure fn filtered(&self, f: fn(t: &T) -> bool) -> ~[T] {
filtered(*self, f)
}
/**
@ -3618,7 +3618,7 @@ fn test_filter_map_fail() {
fn test_filter_fail() {
let v = [(~0, @0), (~0, @0), (~0, @0), (~0, @0)];
let mut i = 0;
do filter(v) |_elt| {
do v.filtered |_elt| {
if i == 2 {
fail
}

View File

@ -262,8 +262,9 @@ fn as_str(f: fn@(+x: io::Writer)) -> ~str {
fn check_variants_of_ast(crate: ast::crate, codemap: @codemap::CodeMap,
filename: &Path, cx: context) {
let stolen = steal(crate, cx.mode);
let extra_exprs = vec::filter(common_exprs(),
|a| safe_to_use_expr(*a, cx.mode) );
let extra_exprs = do common_exprs().filtered |a| {
safe_to_use_expr(*a, cx.mode)
};
check_variants_T(crate, codemap, filename, ~"expr",
extra_exprs + stolen.exprs, pprust::expr_to_str,
replace_expr_in_crate, cx);

View File

@ -103,11 +103,11 @@ fn fold_item_underscore(cx: ctxt, +item: ast::item_,
fld: fold::ast_fold) -> ast::item_ {
let item = match item {
ast::item_impl(a, b, c, methods) => {
let methods = methods.filter(|m| method_in_cfg(cx, *m) );
let methods = methods.filtered(|m| method_in_cfg(cx, *m) );
ast::item_impl(a, b, c, methods)
}
ast::item_trait(ref a, ref b, ref methods) => {
let methods = methods.filter(|m| trait_method_in_cfg(cx, m) );
let methods = methods.filtered(|m| trait_method_in_cfg(cx, m) );
ast::item_trait(/*bad*/copy *a, /*bad*/copy *b, methods)
}
item => item

View File

@ -256,7 +256,7 @@ fn encode_ast(ebml_w: writer::Encoder, item: ast::inlined_item) {
// inlined items.
fn simplify_ast(ii: ast::inlined_item) -> ast::inlined_item {
fn drop_nested_items(blk: ast::blk_, fld: fold::ast_fold) -> ast::blk_ {
let stmts_sans_items = do vec::filter(blk.stmts) |stmt| {
let stmts_sans_items = do blk.stmts.filtered |stmt| {
match stmt.node {
ast::stmt_expr(_, _) | ast::stmt_semi(_, _) |
ast::stmt_decl(@ast::spanned { node: ast::decl_local(_),

View File

@ -174,7 +174,7 @@ fn trans_log(log_ex: @ast::expr,
let modpath = vec::append(
~[path_mod(ccx.sess.ident_of(/*bad*/copy ccx.link_meta.name))],
vec::filter(bcx.fcx.path, |e|
bcx.fcx.path.filtered(|e|
match *e { path_mod(_) => true, _ => false }
));
// XXX: Bad copy.

View File

@ -129,7 +129,7 @@ fn fold_mod(
fn strip_mod(doc: doc::ModDoc) -> doc::ModDoc {
doc::ModDoc_({
items: do vec::filter(doc.items) |item| {
items: do doc.items.filtered |item| {
match *item {
doc::ModTag(_) => false,
doc::NmodTag(_) => false,

View File

@ -43,9 +43,9 @@ fn fold_mod(
let doc = fold::default_any_fold_mod(fold, doc);
doc::ModDoc_({
items: vec::filter(doc.items, |ItemTag| {
items: do doc.items.filtered |ItemTag| {
!is_hidden(fold.ctxt, ItemTag.item())
}),
},
.. *doc
})
}

View File

@ -49,9 +49,9 @@ fn fold_mod(
let doc = fold::default_any_fold_mod(fold, doc);
doc::ModDoc_({
items: do doc.items.filter |ItemTag| {
items: doc.items.filter(|ItemTag| {
is_visible(fold.ctxt, ItemTag.item())
},
}),
.. *doc
})
}

View File

@ -316,11 +316,12 @@ fn ident_to_pat(id: node_id, s: span, +i: ident) -> @pat {
}
fn public_methods(ms: ~[@method]) -> ~[@method] {
vec::filter(ms,
|m| match m.vis {
public => true,
_ => false
})
do ms.filtered |m| {
match m.vis {
public => true,
_ => false
}
}
}
// extract a ty_method from a trait_method. if the trait_method is

View File

@ -121,7 +121,7 @@ fn is_auto_encode(a: &ast::attribute) -> bool {
}
fn filter_attrs(item: @ast::item) -> @ast::item {
@{attrs: vec::filter(item.attrs, |a| !is_auto_encode(a)),
@{attrs: item.attrs.filtered(|a| !is_auto_encode(a)),
.. *item}
}
@ -185,7 +185,7 @@ fn is_auto_decode(a: &ast::attribute) -> bool {
}
fn filter_attrs(item: @ast::item) -> @ast::item {
@{attrs: vec::filter(item.attrs, |a| !is_auto_decode(a)),
@{attrs: item.attrs.filtered(|a| !is_auto_decode(a)),
.. *item}
}