change to use && mode (can't move from upvar)

relevant to #1965
This commit is contained in:
Niko Matsakis 2012-04-12 21:58:32 -07:00
parent 39c5e06526
commit c2fe288900

View file

@ -81,20 +81,20 @@ fn flat_map<A,B,IA:iterable<A>,IB:iterable<B>>(
}
}
fn foldl<A,B,IA:iterable<A>>(self: IA, +b0: B, blk: fn(-B, A) -> B) -> B {
fn foldl<A,B,IA:iterable<A>>(self: IA, +b0: B, blk: fn(B, A) -> B) -> B {
let mut b <- b0;
self.iter {|a|
b = blk(b, a);
b <- blk(b, a);
}
ret b;
}
fn foldr<A:copy,B,IA:iterable<A>>(
self: IA, +b0: B, blk: fn(A, -B) -> B) -> B {
self: IA, +b0: B, blk: fn(A, B) -> B) -> B {
let mut b <- b0;
reversed(self) {|a|
b = blk(a, b);
b <- blk(a, b);
}
ret b;
}
@ -291,7 +291,7 @@ fn test_count() {
#[test]
fn test_foldr() {
fn sub(&&a: int, -b: int) -> int {
fn sub(&&a: int, &&b: int) -> int {
a - b
}
let sum = foldr([1, 2, 3, 4], 0, sub);