@@ -413,7 +413,9 @@ pub fn partition<T>(v: ~[T], f: fn(&T) -> bool) -> (~[T], ~[T]) {
413
413
let mut lefts = ~[ ] ;
414
414
let mut rights = ~[ ] ;
415
415
416
- do v. consume |_, elt| {
416
+ // FIXME (#4355 maybe): using v.consume here crashes
417
+ // do v.consume |_, elt| {
418
+ do consume( v) |_, elt| {
417
419
if f ( & elt) {
418
420
lefts. push ( elt) ;
419
421
} else {
@@ -855,7 +857,9 @@ pub pure fn filter_map<T, U: Copy>(v: &[T], f: fn(t: &T) -> Option<U>)
855
857
*/
856
858
pub fn filter < T > ( v : ~[ T ] , f : fn ( t : & T ) -> bool ) -> ~[ T ] {
857
859
let mut result = ~[ ] ;
858
- do v. consume |_, elem| {
860
+ // FIXME (#4355 maybe): using v.consume here crashes
861
+ // do v.consume |_, elem| {
862
+ do consume( v) |_, elem| {
859
863
if f ( & elem) { result. push ( elem) ; }
860
864
}
861
865
result
@@ -3186,10 +3190,11 @@ mod tests {
3186
3190
3187
3191
#[ test]
3188
3192
fn test_partition ( ) {
3189
- assert ( ~[ ] ) . partition ( |x : & int | * x < 3 ) == ( ~[ ] , ~[ ] ) ;
3190
- assert ( ~[ 1 , 2 , 3 ] ) . partition ( |x : & int | * x < 4 ) == ( ~[ 1 , 2 , 3 ] , ~[ ] ) ;
3191
- assert ( ~[ 1 , 2 , 3 ] ) . partition ( |x : & int | * x < 2 ) == ( ~[ 1 ] , ~[ 2 , 3 ] ) ;
3192
- assert ( ~[ 1 , 2 , 3 ] ) . partition ( |x : & int | * x < 0 ) == ( ~[ ] , ~[ 1 , 2 , 3 ] ) ;
3193
+ // FIXME (#4355 maybe): using v.partition here crashes
3194
+ assert partition ( ~[ ] , |x : & int | * x < 3 ) == ( ~[ ] , ~[ ] ) ;
3195
+ assert partition ( ~[ 1 , 2 , 3 ] , |x : & int | * x < 4 ) == ( ~[ 1 , 2 , 3 ] , ~[ ] ) ;
3196
+ assert partition ( ~[ 1 , 2 , 3 ] , |x : & int | * x < 2 ) == ( ~[ 1 ] , ~[ 2 , 3 ] ) ;
3197
+ assert partition ( ~[ 1 , 2 , 3 ] , |x : & int | * x < 0 ) == ( ~[ ] , ~[ 1 , 2 , 3 ] ) ;
3193
3198
}
3194
3199
3195
3200
#[ test]
0 commit comments