diff options
| author | bors <bors@rust-lang.org> | 2013-07-03 08:16:54 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-07-03 08:16:54 -0700 |
| commit | 0c6fc46c030ab0515a052fa99c9e10c75cfc8184 (patch) | |
| tree | 3840f27f53871ed20b17e82beac7ea9a402dce46 /src/libsyntax | |
| parent | 1cee9d4c38c628914cc72277854bd97f4f017225 (diff) | |
| parent | cdea73cf5b94784fdc910ab23d5d3455c868d247 (diff) | |
| download | rust-0c6fc46c030ab0515a052fa99c9e10c75cfc8184.tar.gz rust-0c6fc46c030ab0515a052fa99c9e10c75cfc8184.zip | |
auto merge of #7566 : huonw/rust/vec-kill, r=cmr
The last remaining internal iterator in `vec` is `each_permutation`.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast_util.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/attr.rs | 13 | ||||
| -rw-r--r-- | src/libsyntax/ext/fmt.rs | 3 | ||||
| -rw-r--r-- | src/libsyntax/fold.rs | 4 |
4 files changed, 7 insertions, 17 deletions
diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 529d5bfe70b..ce8e24fd444 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -238,12 +238,12 @@ pub fn unguarded_pat(a: &arm) -> Option<~[@pat]> { } pub fn public_methods(ms: ~[@method]) -> ~[@method] { - do ms.filtered |m| { + do ms.consume_iter().filter |m| { match m.vis { public => true, _ => false } - } + }.collect() } // extract a ty_method from a trait_method. if the trait_method is diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index a1a0c700628..d04d96b2481 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -143,13 +143,13 @@ pub fn get_name_value_str_pair(item: @ast::meta_item) /// Search a list of attributes and return only those with a specific name pub fn find_attrs_by_name(attrs: &[ast::attribute], name: &str) -> ~[ast::attribute] { - do vec::filter_mapped(attrs) |a| { + do attrs.iter().filter_map |a| { if name == get_attr_name(a) { Some(*a) } else { None } - } + }.collect() } /// Search a list of meta items and return only those with a specific name @@ -277,14 +277,7 @@ pub fn sort_meta_items(items: &[@ast::meta_item]) -> ~[@ast::meta_item] { pub fn remove_meta_items_by_name(items: ~[@ast::meta_item], name: &str) -> ~[@ast::meta_item] { - - return vec::filter_mapped(items, |item| { - if name != get_meta_item_name(*item) { - Some(*item) - } else { - None - } - }); + items.consume_iter().filter(|item| name != get_meta_item_name(*item)).collect() } /** diff --git a/src/libsyntax/ext/fmt.rs b/src/libsyntax/ext/fmt.rs index 76073199f64..333570b6c9d 100644 --- a/src/libsyntax/ext/fmt.rs +++ b/src/libsyntax/ext/fmt.rs @@ -22,7 +22,6 @@ use ext::build::AstBuilder; use std::option; use std::unstable::extfmt::ct::*; -use std::vec; use parse::token::{str_to_ident}; pub fn expand_syntax_ext(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree]) @@ -268,7 +267,7 @@ fn pieces_to_expr(cx: @ExtCtxt, sp: span, corresponding function in std::unstable::extfmt. Each function takes a buffer to insert data into along with the data being formatted. */ let npieces = pieces.len(); - do vec::consume(pieces) |i, pc| { + for pieces.consume_iter().enumerate().advance |(i, pc)| { match pc { /* Raw strings get appended via str::push_str */ PieceString(s) => { diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 4e145123996..96d7685353b 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -14,8 +14,6 @@ use codemap::{span, spanned}; use parse::token; use opt_vec::OptVec; -use std::vec; - pub trait ast_fold { fn fold_crate(@self, &crate) -> crate; fn fold_view_item(@self, @view_item) -> @view_item; @@ -700,7 +698,7 @@ pub fn noop_fold_ty(t: &ty_, fld: @ast_fold) -> ty_ { pub fn noop_fold_mod(m: &_mod, fld: @ast_fold) -> _mod { ast::_mod { view_items: m.view_items.iter().transform(|x| fld.fold_view_item(*x)).collect(), - items: vec::filter_mapped(m.items, |x| fld.fold_item(*x)), + items: m.items.iter().filter_map(|x| fld.fold_item(*x)).collect(), } } |
