@@ -1564,7 +1564,7 @@ pub fn each<'r,T>(v: &'r [T], f: &fn(&'r T) -> bool) -> bool {
1564
1564
}
1565
1565
broke = n > 0 ;
1566
1566
}
1567
- return true ;
1567
+ return !broke ;
1568
1568
}
1569
1569
1570
1570
/// Like `each()`, but for the case where you have
@@ -1586,7 +1586,7 @@ pub fn each_mut<'r,T>(v: &'r mut [T], f: &fn(elem: &'r mut T) -> bool) -> bool {
1586
1586
}
1587
1587
broke = n > 0 ;
1588
1588
}
1589
- return broke;
1589
+ return ! broke;
1590
1590
}
1591
1591
1592
1592
/// Like `each()`, but for the case where you have a vector that *may or may
@@ -3598,6 +3598,23 @@ mod tests {
3598
3598
}
3599
3599
}
3600
3600
3601
+ #[ test]
3602
+ fn test_each_ret_len0 ( ) {
3603
+ let mut a0 : [ int , .. 0 ] = [ ] ;
3604
+ assert_eq ! ( each( a0, |_p| fail!( ) ) , true ) ;
3605
+ assert_eq ! ( each_mut( a0, |_p| fail!( ) ) , true ) ;
3606
+ }
3607
+
3608
+ #[ test]
3609
+ fn test_each_ret_len1 ( ) {
3610
+ let mut a1 = [ 17 ] ;
3611
+ assert_eq ! ( each( a1, |_p| true ) , true ) ;
3612
+ assert_eq ! ( each_mut( a1, |_p| true ) , true ) ;
3613
+ assert_eq ! ( each( a1, |_p| false ) , false ) ;
3614
+ assert_eq ! ( each_mut( a1, |_p| false ) , false ) ;
3615
+ }
3616
+
3617
+
3601
3618
#[ test]
3602
3619
fn test_each_permutation ( ) {
3603
3620
let mut results: ~[ ~[ int ] ] ;
0 commit comments