diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index 761b82c05826ce7b1838c61af787227ad8ef729e..f84c1a9f0beeaea7d71e937eb5207d8f938e4f46 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -413,7 +413,9 @@ pub fn partition(v: ~[T], f: fn(&T) -> bool) -> (~[T], ~[T]) { let mut lefts = ~[]; let mut rights = ~[]; - do v.consume |_, elt| { + // FIXME (#4355 maybe): using v.consume here crashes + // do v.consume |_, elt| { + do consume(v) |_, elt| { if f(&elt) { lefts.push(elt); } else { @@ -855,7 +857,9 @@ pub fn map_consume(v: ~[T], f: fn(v: T) -> U) -> ~[U] { */ pub fn filter(v: ~[T], f: fn(t: &T) -> bool) -> ~[T] { let mut result = ~[]; - do v.consume |_, elem| { + // FIXME (#4355 maybe): using v.consume here crashes + // do v.consume |_, elem| { + do consume(v) |_, elem| { if f(&elem) { result.push(elem); } } result @@ -3186,10 +3190,11 @@ fn f(x: &int) -> bool { *x == 3 } #[test] fn test_partition() { - assert (~[]).partition(|x: &int| *x < 3) == (~[], ~[]); - assert (~[1, 2, 3]).partition(|x: &int| *x < 4) == (~[1, 2, 3], ~[]); - assert (~[1, 2, 3]).partition(|x: &int| *x < 2) == (~[1], ~[2, 3]); - assert (~[1, 2, 3]).partition(|x: &int| *x < 0) == (~[], ~[1, 2, 3]); + // FIXME (#4355 maybe): using v.partition here crashes + assert partition(~[], |x: &int| *x < 3) == (~[], ~[]); + assert partition(~[1, 2, 3], |x: &int| *x < 4) == (~[1, 2, 3], ~[]); + assert partition(~[1, 2, 3], |x: &int| *x < 2) == (~[1], ~[2, 3]); + assert partition(~[1, 2, 3], |x: &int| *x < 0) == (~[], ~[1, 2, 3]); } #[test]