@@ -1532,7 +1532,7 @@ pub fn each<'r,T>(v: &'r [T], f: &fn(&'r T) -> bool) -> bool {
1532
1532
}
1533
1533
broke = n > 0 ;
1534
1534
}
1535
- return true ;
1535
+ return !broke ;
1536
1536
}
1537
1537
1538
1538
/// Like `each()`, but for the case where you have
@@ -1554,7 +1554,7 @@ pub fn each_mut<'r,T>(v: &'r mut [T], f: &fn(elem: &'r mut T) -> bool) -> bool {
1554
1554
}
1555
1555
broke = n > 0 ;
1556
1556
}
1557
- return broke;
1557
+ return ! broke;
1558
1558
}
1559
1559
1560
1560
/// Like `each()`, but for the case where you have a vector that *may or may
@@ -3566,6 +3566,23 @@ mod tests {
3566
3566
}
3567
3567
}
3568
3568
3569
+ #[ test]
3570
+ fn test_each_ret_len0 ( ) {
3571
+ let mut a0 : [ int , .. 0 ] = [ ] ;
3572
+ assert_eq ! ( each( a0, |_p| fail!( ) ) , true ) ;
3573
+ assert_eq ! ( each_mut( a0, |_p| fail!( ) ) , true ) ;
3574
+ }
3575
+
3576
+ #[ test]
3577
+ fn test_each_ret_len1 ( ) {
3578
+ let mut a1 = [ 17 ] ;
3579
+ assert_eq ! ( each( a1, |_p| true ) , true ) ;
3580
+ assert_eq ! ( each_mut( a1, |_p| true ) , true ) ;
3581
+ assert_eq ! ( each( a1, |_p| false ) , false ) ;
3582
+ assert_eq ! ( each_mut( a1, |_p| false ) , false ) ;
3583
+ }
3584
+
3585
+
3569
3586
#[ test]
3570
3587
fn test_each_permutation ( ) {
3571
3588
let mut results: ~[ ~[ int ] ] ;
0 commit comments