Skip to content

Commit 7e0fa3f

Browse files
committed
std: Swap the argument order of list::foldl to match vec::foldl
1 parent 5e8004d commit 7e0fa3f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/libstd/list.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ accumulated result.
2727
* z - The initial value
2828
* f - The function to apply
2929
"]
30-
fn foldl<T: copy, U>(ls: list<U>, z: T, f: fn(T, U) -> T) -> T {
30+
fn foldl<T: copy, U>(z: T, ls: list<U>, f: fn(T, U) -> T) -> T {
3131
let mut accum: T = z;
3232
iter(ls) {|elt| accum = f(accum, elt);}
3333
accum
@@ -180,8 +180,8 @@ mod tests {
180180
fn add(&&a: uint, &&b: int) -> uint { ret a + (b as uint); }
181181
let l = from_vec([0, 1, 2, 3, 4]);
182182
let empty = list::nil::<int>;
183-
assert (list::foldl(l, 0u, add) == 10u);
184-
assert (list::foldl(empty, 0u, add) == 0u);
183+
assert (list::foldl(0u, l, add) == 10u);
184+
assert (list::foldl(0u, empty, add) == 0u);
185185
}
186186

187187
#[test]
@@ -190,7 +190,7 @@ mod tests {
190190
a - b
191191
}
192192
let l = from_vec([1, 2, 3, 4]);
193-
assert (list::foldl(l, 0, sub) == -10);
193+
assert (list::foldl(0, l, sub) == -10);
194194
}
195195

196196
#[test]

0 commit comments

Comments
 (0)