Skip to content

Commit 8b612b3

Browse files
committed
---
yaml --- r: 63122 b: refs/heads/snap-stage3 c: ed299af h: refs/heads/master v: v3
1 parent 4e2e48c commit 8b612b3

26 files changed

+73
-194
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 65c7c58c8f15189d2e4ca6b166e933c5fe2d0691
4+
refs/heads/snap-stage3: ed299af62566a9f0f285e81408aab5f7680ab4cc
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/doc/tutorial-tasks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ a single large vector of floats. Each task needs the full vector to perform its
354354
use extra::arc::ARC;
355355
356356
fn pnorm(nums: &~[float], p: uint) -> float {
357-
(vec::foldl(0.0, *nums, |a,b| a+(*b).pow(p as float) )).pow(1f / (p as float))
357+
nums.iter().fold(0.0, |a,b| a+(*b).pow(p as float) ).pow(1f / (p as float))
358358
}
359359
360360
fn main() {

branches/snap-stage3/src/libextra/dlist.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Do not use ==, !=, <, etc on doubly-linked lists -- it may not terminate.
2020

2121
use core::prelude::*;
2222

23+
use core::iterator::IteratorUtil;
2324
use core::managed;
2425
use core::old_iter;
2526
use core::vec;
@@ -110,7 +111,7 @@ pub fn from_elem<T>(data: T) -> @mut DList<T> {
110111

111112
/// Creates a new dlist from a vector of elements, maintaining the same order
112113
pub fn from_vec<T:Copy>(vec: &[T]) -> @mut DList<T> {
113-
do vec::foldl(DList(), vec) |list,data| {
114+
do vec.iter().fold(DList()) |list,data| {
114115
list.push(*data); // Iterating left-to-right -- add newly to the tail.
115116
list
116117
}

branches/snap-stage3/src/libextra/list.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313
use core::prelude::*;
1414

15-
use core::vec;
15+
use core::iterator::IteratorUtil;
1616

1717
#[deriving(Eq)]
1818
pub enum List<T> {
@@ -28,7 +28,7 @@ pub enum MutList<T> {
2828

2929
/// Create a list from a vector
3030
pub fn from_vec<T:Copy>(v: &[T]) -> @List<T> {
31-
vec::foldr(v, @Nil::<T>, |h, t| @Cons(*h, t))
31+
v.rev_iter().fold(@Nil::<T>, |t, h| @Cons(*h, t))
3232
}
3333

3434
/**

branches/snap-stage3/src/libextra/stats.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
use core::prelude::*;
1414

15+
use core::iterator::*;
1516
use core::vec;
1617
use core::f64;
1718
use core::cmp;
@@ -36,17 +37,17 @@ pub trait Stats {
3637

3738
impl<'self> Stats for &'self [f64] {
3839
fn sum(self) -> f64 {
39-
vec::foldl(0.0, self, |p,q| p + *q)
40+
self.iter().fold(0.0, |p,q| p + *q)
4041
}
4142

4243
fn min(self) -> f64 {
4344
assert!(self.len() != 0);
44-
vec::foldl(self[0], self, |p,q| cmp::min(p, *q))
45+
self.iter().fold(self[0], |p,q| cmp::min(p, *q))
4546
}
4647

4748
fn max(self) -> f64 {
4849
assert!(self.len() != 0);
49-
vec::foldl(self[0], self, |p,q| cmp::max(p, *q))
50+
self.iter().fold(self[0], |p,q| cmp::max(p, *q))
5051
}
5152

5253
fn mean(self) -> f64 {

branches/snap-stage3/src/librustc/middle/const_eval.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use middle;
1818
use syntax::{ast, ast_map, ast_util, visit};
1919
use syntax::ast::*;
2020

21+
use core::iterator::IteratorUtil;
2122
use core::float;
2223
use core::hashmap::{HashMap, HashSet};
2324
use core::vec;
@@ -72,7 +73,7 @@ pub fn join(a: constness, b: constness) -> constness {
7273
}
7374

7475
pub fn join_all(cs: &[constness]) -> constness {
75-
vec::foldl(integral_const, cs, |a, b| join(a, *b))
76+
cs.iter().fold(integral_const, |a, b| join(a, *b))
7677
}
7778

7879
pub fn classify(e: @expr,

branches/snap-stage3/src/librustc/middle/trans/cabi_arm.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use middle::trans::cabi::{ABIInfo, FnType, LLVMType};
1717
use middle::trans::common::{T_i8, T_i16, T_i32, T_i64};
1818
use middle::trans::common::{T_array, T_ptr, T_void};
1919

20+
use core::iterator::IteratorUtil;
2021
use core::option::{Option, None, Some};
2122
use core::uint;
2223
use core::vec;
@@ -43,9 +44,8 @@ fn ty_align(ty: TypeRef) -> uint {
4344
if llvm::LLVMIsPackedStruct(ty) == True {
4445
1
4546
} else {
46-
do vec::foldl(1, struct_tys(ty)) |a, t| {
47-
uint::max(a, ty_align(*t))
48-
}
47+
let str_tys = struct_tys(ty);
48+
str_tys.iter().fold(1, |a, t| uint::max(a, ty_align(*t)))
4949
}
5050
}
5151
Array => {
@@ -68,13 +68,11 @@ fn ty_size(ty: TypeRef) -> uint {
6868
Double => 8,
6969
Struct => {
7070
if llvm::LLVMIsPackedStruct(ty) == True {
71-
do vec::foldl(0, struct_tys(ty)) |s, t| {
72-
s + ty_size(*t)
73-
}
71+
let str_tys = struct_tys(ty);
72+
str_tys.iter().fold(0, |s, t| s + ty_size(*t))
7473
} else {
75-
let size = do vec::foldl(0, struct_tys(ty)) |s, t| {
76-
align(s, *t) + ty_size(*t)
77-
};
74+
let str_tys = struct_tys(ty);
75+
let size = str_tys.iter().fold(0, |s, t| align(s, *t) + ty_size(*t));
7876
align(size, ty)
7977
}
8078
}

branches/snap-stage3/src/librustc/middle/trans/cabi_mips.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use core::prelude::*;
1212

13+
use core::iterator::IteratorUtil;
1314
use core::libc::c_uint;
1415
use core::ptr;
1516
use core::uint;
@@ -56,9 +57,8 @@ fn ty_align(ty: TypeRef) -> uint {
5657
if llvm::LLVMIsPackedStruct(ty) == True {
5758
1
5859
} else {
59-
do vec::foldl(1, struct_tys(ty)) |a, t| {
60-
uint::max(a, ty_align(*t))
61-
}
60+
let str_tys = struct_tys(ty);
61+
str_tys.iter().fold(1, |a, t| uint::max(a, ty_align(*t)))
6262
}
6363
}
6464
Array => {
@@ -81,13 +81,11 @@ fn ty_size(ty: TypeRef) -> uint {
8181
Double => 8,
8282
Struct => {
8383
if llvm::LLVMIsPackedStruct(ty) == True {
84-
do vec::foldl(0, struct_tys(ty)) |s, t| {
85-
s + ty_size(*t)
86-
}
84+
let str_tys = struct_tys(ty);
85+
str_tys.iter().fold(0, |s, t| s + ty_size(*t))
8786
} else {
88-
let size = do vec::foldl(0, struct_tys(ty)) |s, t| {
89-
align(s, *t) + ty_size(*t)
90-
};
87+
let str_tys = struct_tys(ty);
88+
let size = str_tys.iter().fold(0, |s, t| align(s, *t) + ty_size(*t));
9189
align(size, ty)
9290
}
9391
}

branches/snap-stage3/src/librustc/middle/trans/cabi_x86_64.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use lib::llvm::True;
1919
use middle::trans::common::*;
2020
use middle::trans::cabi::*;
2121

22+
use core::iterator::IteratorUtil;
2223
use core::libc::c_uint;
2324
use core::option;
2425
use core::option::Option;
@@ -80,9 +81,8 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
8081
if llvm::LLVMIsPackedStruct(ty) == True {
8182
1
8283
} else {
83-
do vec::foldl(1, struct_tys(ty)) |a, t| {
84-
uint::max(a, ty_align(*t))
85-
}
84+
let str_tys = struct_tys(ty);
85+
str_tys.iter().fold(1, |a, t| uint::max(a, ty_align(*t)))
8686
}
8787
}
8888
Array => {
@@ -104,16 +104,14 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
104104
Float => 4,
105105
Double => 8,
106106
Struct => {
107-
if llvm::LLVMIsPackedStruct(ty) == True {
108-
do vec::foldl(0, struct_tys(ty)) |s, t| {
109-
s + ty_size(*t)
107+
if llvm::LLVMIsPackedStruct(ty) == True {
108+
let str_tys = struct_tys(ty);
109+
str_tys.iter().fold(0, |s, t| s + ty_size(*t))
110+
} else {
111+
let str_tys = struct_tys(ty);
112+
let size = str_tys.iter().fold(0, |s, t| align(s, *t) + ty_size(*t));
113+
align(size, ty)
110114
}
111-
} else {
112-
let size = do vec::foldl(0, struct_tys(ty)) |s, t| {
113-
align(s, *t) + ty_size(*t)
114-
};
115-
align(size, ty)
116-
}
117115
}
118116
Array => {
119117
let len = llvm::LLVMGetArrayLength(ty) as uint;

branches/snap-stage3/src/librustdoc/desc_to_brief_pass.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use fold::Fold;
2424
use fold;
2525
use pass::Pass;
2626

27+
use core::iterator::IteratorUtil;
2728
use core::str;
2829
use core::util;
2930
use core::vec;
@@ -150,7 +151,7 @@ pub fn paragraphs(s: &str) -> ~[~str] {
150151
for str::each_line_any(s) |line| { lines.push(line.to_owned()); }
151152
let mut whitespace_lines = 0;
152153
let mut accum = ~"";
153-
let paras = do vec::foldl(~[], lines) |paras, line| {
154+
let paras = do lines.iter().fold(~[]) |paras, line| {
154155
let mut res = paras;
155156

156157
if str::is_whitespace(*line) {

branches/snap-stage3/src/librustdoc/doc.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use core::prelude::*;
1414

1515
use doc;
1616

17+
use core::iterator::IteratorUtil;
1718
use core::vec;
1819

1920
pub type AstId = int;
@@ -174,7 +175,7 @@ pub struct IndexEntry {
174175

175176
impl Doc {
176177
pub fn CrateDoc(&self) -> CrateDoc {
177-
vec::foldl(None, self.pages, |_m, page| {
178+
self.pages.iter().fold(None, |_m, page| {
178179
match copy *page {
179180
doc::CratePage(doc) => Some(doc),
180181
_ => None

branches/snap-stage3/src/librustdoc/pass.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use core::prelude::*;
1212

1313
use core::vec;
14+
use core::iterator::IteratorUtil;
1415

1516
use astsrv;
1617
use doc;
@@ -30,7 +31,7 @@ pub fn run_passes(
3031
passes: ~[Pass]
3132
) -> doc::Doc {
3233
let mut passno = 0;
33-
do vec::foldl(doc, passes) |doc, pass| {
34+
do passes.iter().fold(doc) |doc, pass| {
3435
debug!("pass #%d", passno);
3536
passno += 1;
3637
do time(copy pass.name) {

branches/snap-stage3/src/librustdoc/unindent_pass.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ middle of a line, and each of the following lines is indented.
2121

2222
use core::prelude::*;
2323

24+
use core::iterator::IteratorUtil;
2425
use core::str;
2526
use core::uint;
2627
use core::vec;
@@ -36,7 +37,7 @@ fn unindent(s: &str) -> ~str {
3637
for str::each_line_any(s) |line| { lines.push(line.to_owned()); }
3738
let mut saw_first_line = false;
3839
let mut saw_second_line = false;
39-
let min_indent = do vec::foldl(uint::max_value, lines)
40+
let min_indent = do lines.iter().fold(uint::max_value)
4041
|min_indent, line| {
4142

4243
// After we see the first non-whitespace line, look at

0 commit comments

Comments
 (0)