diff options
| author | Huon Wilson <dbau.pp+github@gmail.com> | 2013-06-08 15:12:39 +1000 |
|---|---|---|
| committer | Huon Wilson <dbau.pp+github@gmail.com> | 2013-06-09 02:22:23 +1000 |
| commit | ed299af62566a9f0f285e81408aab5f7680ab4cc (patch) | |
| tree | 39d540d5fa2b0aee7b88859e1644668a96b67be2 /src/libsyntax | |
| parent | 65c7c58c8f15189d2e4ca6b166e933c5fe2d0691 (diff) | |
| download | rust-ed299af62566a9f0f285e81408aab5f7680ab4cc.tar.gz rust-ed299af62566a9f0f285e81408aab5f7680ab4cc.zip | |
std: remove fold[lr] in favour of iterators
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/attr.rs | 3 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/iter_bytes.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 3 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/macro_parser.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/transcribe.rs | 10 |
5 files changed, 12 insertions, 12 deletions
diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 2da64563159..51334772c84 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -19,6 +19,7 @@ use codemap::BytePos; use diagnostic::span_handler; use parse::comments::{doc_comment_style, strip_doc_comment_decoration}; +use core::iterator::IteratorUtil; use core::hashmap::HashSet; use core::vec; use extra; @@ -313,7 +314,7 @@ pub enum inline_attr { /// True if something like #[inline] is found in the list of attrs. pub fn find_inline_attr(attrs: &[ast::attribute]) -> inline_attr { // FIXME (#2809)---validate the usage of #[inline] and #[inline(always)] - do vec::foldl(ia_none, attrs) |ia,attr| { + do attrs.iter().fold(ia_none) |ia,attr| { match attr.node.value.node { ast::meta_word(@~"inline") => ia_hint, ast::meta_list(@~"inline", ref items) => { diff --git a/src/libsyntax/ext/deriving/iter_bytes.rs b/src/libsyntax/ext/deriving/iter_bytes.rs index 13f83b55a40..453d867fce9 100644 --- a/src/libsyntax/ext/deriving/iter_bytes.rs +++ b/src/libsyntax/ext/deriving/iter_bytes.rs @@ -16,7 +16,7 @@ use ext::base::ExtCtxt; use ext::build::AstBuilder; use ext::deriving::generic::*; -use core::vec; +use core::iterator::IteratorUtil; pub fn expand_deriving_iter_bytes(cx: @ExtCtxt, span: span, @@ -85,7 +85,7 @@ fn iter_bytes_substructure(cx: @ExtCtxt, span: span, substr: &Substructure) -> @ cx.span_bug(span, "#[deriving(IterBytes)] needs at least one field"); } - do vec::foldl(exprs[0], exprs.slice(1, exprs.len())) |prev, me| { + do exprs.slice(1, exprs.len()).iter().fold(exprs[0]) |prev, me| { cx.expr_binary(span, and, prev, *me) } } diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index e1f31b83524..1630fb11626 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -27,6 +27,7 @@ use parse::token::{ident_to_str, intern, fresh_name}; use visit; use visit::{Visitor,mk_vt}; +use core::iterator::IteratorUtil; use core::vec; pub fn expand_expr(extsbox: @mut SyntaxEnv, @@ -128,7 +129,7 @@ pub fn expand_mod_items(extsbox: @mut SyntaxEnv, // decorated with "item decorators", then use that function to transform // the item into a new set of items. let new_items = do vec::flat_map(module_.items) |item| { - do vec::foldr(item.attrs, ~[*item]) |attr, items| { + do item.attrs.rev_iter().fold(~[*item]) |items, attr| { let mname = attr::get_attr_name(attr); match (*extsbox).find(&intern(*mname)) { diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 5f43452cc83..a6ec91f899c 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -129,12 +129,12 @@ pub fn copy_up(mpu: &matcher_pos_up) -> ~MatcherPos { } pub fn count_names(ms: &[matcher]) -> uint { - vec::foldl(0u, ms, |ct, m| { + do ms.iter().fold(0) |ct, m| { ct + match m.node { match_tok(_) => 0u, match_seq(ref more_ms, _, _, _, _) => count_names((*more_ms)), match_nonterminal(_,_,_) => 1u - }}) + }} } pub fn initial_matcher_pos(ms: ~[matcher], sep: Option<Token>, lo: BytePos) diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index f8a783c568a..f3bd2d4b8d1 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -19,9 +19,9 @@ use parse::token::{EOF, INTERPOLATED, IDENT, Token, nt_ident}; use parse::token::{ident_to_str}; use parse::lexer::TokenAndSpan; +use core::iterator::IteratorUtil; use core::hashmap::HashMap; use core::option; -use core::vec; ///an unzipping of `token_tree`s struct TtFrame { @@ -113,9 +113,7 @@ fn lookup_cur_matched_by_matched(r: &mut TtReader, matched_seq(ref ads, _) => ads[*idx] } } - let r = &mut *r; - let repeat_idx = &r.repeat_idx; - vec::foldl(start, *repeat_idx, red) + r.repeat_idx.iter().fold(start, red) } fn lookup_cur_matched(r: &mut TtReader, name: ident) -> @named_match { @@ -152,10 +150,10 @@ fn lockstep_iter_size(t: &token_tree, r: &mut TtReader) -> lis { } match *t { tt_delim(ref tts) | tt_seq(_, ref tts, _, _) => { - vec::foldl(lis_unconstrained, *tts, |lis, tt| { + do tts.iter().fold(lis_unconstrained) |lis, tt| { let lis2 = lockstep_iter_size(tt, r); lis_merge(lis, lis2) - }) + } } tt_tok(*) => lis_unconstrained, tt_nonterminal(_, name) => match *lookup_cur_matched(r, name) { |
