File tree 2 files changed +13
-0
lines changed
2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -741,6 +741,16 @@ macro_rules! map_impl {
741
741
/// Tests if every element of the iterator matches a predicate.
742
742
///
743
743
/// Returns `true` if `predicate` evaluates to `true` for all elements.
744
+ /// Returns `true` if the input arrays are empty.
745
+ ///
746
+ /// Example:
747
+ ///
748
+ /// ```
749
+ /// use ndarray::{array, Zip};
750
+ /// let a = array![1, 2, 3];
751
+ /// let b = array![1, 4, 9];
752
+ /// assert!(Zip::from(&a).and(&b).all(|&a, &b| a * a == b));
753
+ /// ```
744
754
pub fn all<F >( mut self , mut predicate: F ) -> bool
745
755
where F : FnMut ( $( $p:: Item ) ,* ) -> bool
746
756
{
Original file line number Diff line number Diff line change @@ -276,8 +276,11 @@ fn test_indices_split_1() {
276
276
fn test_zip_all ( ) {
277
277
let a = Array :: < f32 , _ > :: zeros ( 62 ) ;
278
278
let b = Array :: < f32 , _ > :: ones ( 62 ) ;
279
+ let mut c = Array :: < f32 , _ > :: ones ( 62 ) ;
280
+ c[ 5 ] = 0.0 ;
279
281
assert_eq ! ( true , Zip :: from( & a) . and( & b) . all( |& x, & y| x + y == 1.0 ) ) ;
280
282
assert_eq ! ( false , Zip :: from( & a) . and( & b) . all( |& x, & y| x == y) ) ;
283
+ assert_eq ! ( false , Zip :: from( & a) . and( & c) . all( |& x, & y| x + y == 1.0 ) ) ;
281
284
}
282
285
283
286
#[ test]
You can’t perform that action at this time.
0 commit comments