Skip to content

Commit 2891a49

Browse files
committed
core: rename vec.filter to vec.filtered
1 parent 9a7e261 commit 2891a49

File tree

12 files changed

+27
-25
lines changed

12 files changed

+27
-25
lines changed

src/compiletest/runtest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ fn make_run_args(config: config, _props: test_props, testfile: &Path) ->
526526

527527
fn split_maybe_args(argstr: Option<~str>) -> ~[~str] {
528528
fn rm_whitespace(v: ~[~str]) -> ~[~str] {
529-
vec::filter(v, |s| !str::is_whitespace(*s))
529+
v.filtered(|s| !str::is_whitespace(*s))
530530
}
531531

532532
match argstr {

src/libcore/os.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ pub fn list_dir(p: &Path) -> ~[~str] {
619619
#[cfg(windows)]
620620
fn star(p: &Path) -> Path { p.push("*") }
621621

622-
do rustrt::rust_list_files2(star(p).to_str()).filter |filename| {
622+
do rustrt::rust_list_files2(star(p).to_str()).filtered |filename| {
623623
*filename != ~"." && *filename != ~".."
624624
}
625625
}

src/libcore/vec.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ pub pure fn filter_map<T, U: Copy>(v: &[T], f: fn(t: &T) -> Option<U>)
853853
* Apply function `f` to each element of `v` and return a vector containing
854854
* only those elements for which `f` returned true.
855855
*/
856-
pub pure fn filter<T: Copy>(v: &[T], f: fn(t: &T) -> bool) -> ~[T] {
856+
pub pure fn filtered<T: Copy>(v: &[T], f: fn(t: &T) -> bool) -> ~[T] {
857857
let mut result = ~[];
858858
for each(v) |elem| {
859859
if f(elem) { unsafe { result.push(*elem); } }
@@ -1752,7 +1752,7 @@ impl<T: Eq> &[T]: ImmutableEqVector<T> {
17521752
}
17531753

17541754
pub trait ImmutableCopyableVector<T> {
1755-
pure fn filter(&self, f: fn(t: &T) -> bool) -> ~[T];
1755+
pure fn filtered(&self, f: fn(&T) -> bool) -> ~[T];
17561756
pure fn rfind(&self, f: fn(t: &T) -> bool) -> Option<T>;
17571757
pure fn partitioned(&self, f: fn(&T) -> bool) -> (~[T], ~[T]);
17581758
}
@@ -1767,8 +1767,8 @@ impl<T: Copy> &[T]: ImmutableCopyableVector<T> {
17671767
* containing only those elements for which `f` returned true.
17681768
*/
17691769
#[inline]
1770-
pure fn filter(&self, f: fn(t: &T) -> bool) -> ~[T] {
1771-
filter(*self, f)
1770+
pure fn filtered(&self, f: fn(t: &T) -> bool) -> ~[T] {
1771+
filtered(*self, f)
17721772
}
17731773

17741774
/**
@@ -3618,7 +3618,7 @@ mod tests {
36183618
fn test_filter_fail() {
36193619
let v = [(~0, @0), (~0, @0), (~0, @0), (~0, @0)];
36203620
let mut i = 0;
3621-
do filter(v) |_elt| {
3621+
do v.filtered |_elt| {
36223622
if i == 2 {
36233623
fail
36243624
}

src/libfuzzer/fuzzer.rc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,9 @@ fn as_str(f: fn@(+x: io::Writer)) -> ~str {
262262
fn check_variants_of_ast(crate: ast::crate, codemap: @codemap::CodeMap,
263263
filename: &Path, cx: context) {
264264
let stolen = steal(crate, cx.mode);
265-
let extra_exprs = vec::filter(common_exprs(),
266-
|a| safe_to_use_expr(*a, cx.mode) );
265+
let extra_exprs = do common_exprs().filtered |a| {
266+
safe_to_use_expr(*a, cx.mode)
267+
};
267268
check_variants_T(crate, codemap, filename, ~"expr",
268269
extra_exprs + stolen.exprs, pprust::expr_to_str,
269270
replace_expr_in_crate, cx);

src/librustc/front/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ fn fold_item_underscore(cx: ctxt, +item: ast::item_,
103103
fld: fold::ast_fold) -> ast::item_ {
104104
let item = match item {
105105
ast::item_impl(a, b, c, methods) => {
106-
let methods = methods.filter(|m| method_in_cfg(cx, *m) );
106+
let methods = methods.filtered(|m| method_in_cfg(cx, *m) );
107107
ast::item_impl(a, b, c, methods)
108108
}
109109
ast::item_trait(ref a, ref b, ref methods) => {
110-
let methods = methods.filter(|m| trait_method_in_cfg(cx, m) );
110+
let methods = methods.filtered(|m| trait_method_in_cfg(cx, m) );
111111
ast::item_trait(/*bad*/copy *a, /*bad*/copy *b, methods)
112112
}
113113
item => item

src/librustc/middle/astencode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ fn encode_ast(ebml_w: writer::Encoder, item: ast::inlined_item) {
256256
// inlined items.
257257
fn simplify_ast(ii: ast::inlined_item) -> ast::inlined_item {
258258
fn drop_nested_items(blk: ast::blk_, fld: fold::ast_fold) -> ast::blk_ {
259-
let stmts_sans_items = do vec::filter(blk.stmts) |stmt| {
259+
let stmts_sans_items = do blk.stmts.filtered |stmt| {
260260
match stmt.node {
261261
ast::stmt_expr(_, _) | ast::stmt_semi(_, _) |
262262
ast::stmt_decl(@ast::spanned { node: ast::decl_local(_),

src/librustc/middle/trans/controlflow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ fn trans_log(log_ex: @ast::expr,
174174

175175
let modpath = vec::append(
176176
~[path_mod(ccx.sess.ident_of(/*bad*/copy ccx.link_meta.name))],
177-
vec::filter(bcx.fcx.path, |e|
177+
bcx.fcx.path.filtered(|e|
178178
match *e { path_mod(_) => true, _ => false }
179179
));
180180
// XXX: Bad copy.

src/librustdoc/page_pass.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ fn fold_mod(
129129

130130
fn strip_mod(doc: doc::ModDoc) -> doc::ModDoc {
131131
doc::ModDoc_({
132-
items: do vec::filter(doc.items) |item| {
132+
items: do doc.items.filtered |item| {
133133
match *item {
134134
doc::ModTag(_) => false,
135135
doc::NmodTag(_) => false,

src/librustdoc/prune_hidden_pass.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ fn fold_mod(
4343
let doc = fold::default_any_fold_mod(fold, doc);
4444

4545
doc::ModDoc_({
46-
items: vec::filter(doc.items, |ItemTag| {
46+
items: do doc.items.filtered |ItemTag| {
4747
!is_hidden(fold.ctxt, ItemTag.item())
48-
}),
48+
},
4949
.. *doc
5050
})
5151
}

src/librustdoc/prune_private_pass.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ fn fold_mod(
4949
let doc = fold::default_any_fold_mod(fold, doc);
5050

5151
doc::ModDoc_({
52-
items: do doc.items.filter |ItemTag| {
52+
items: doc.items.filter(|ItemTag| {
5353
is_visible(fold.ctxt, ItemTag.item())
54-
},
54+
}),
5555
.. *doc
5656
})
5757
}

src/libsyntax/ast_util.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -316,11 +316,12 @@ pure fn unguarded_pat(a: &arm) -> Option<~[@pat]> {
316316
}
317317

318318
fn public_methods(ms: ~[@method]) -> ~[@method] {
319-
vec::filter(ms,
320-
|m| match m.vis {
321-
public => true,
322-
_ => false
323-
})
319+
do ms.filtered |m| {
320+
match m.vis {
321+
public => true,
322+
_ => false
323+
}
324+
}
324325
}
325326

326327
// extract a ty_method from a trait_method. if the trait_method is

src/libsyntax/ext/auto_encode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ fn expand_auto_encode(
121121
}
122122

123123
fn filter_attrs(item: @ast::item) -> @ast::item {
124-
@{attrs: vec::filter(item.attrs, |a| !is_auto_encode(a)),
124+
@{attrs: item.attrs.filtered(|a| !is_auto_encode(a)),
125125
.. *item}
126126
}
127127

@@ -185,7 +185,7 @@ fn expand_auto_decode(
185185
}
186186

187187
fn filter_attrs(item: @ast::item) -> @ast::item {
188-
@{attrs: vec::filter(item.attrs, |a| !is_auto_decode(a)),
188+
@{attrs: item.attrs.filtered(|a| !is_auto_decode(a)),
189189
.. *item}
190190
}
191191

0 commit comments

Comments
 (0)