@@ -518,7 +518,7 @@ impl<A, D: Dimension> NdProducer for RawArrayViewMut<A, D> {
518518/// The order elements are visited is not specified. The producers don’t have to
519519/// have the same item type.
520520///
521- /// The `Zip` has two methods for function application: `apply ` and
521+ /// The `Zip` has two methods for function application: `for_each ` and
522522/// `fold_while`. The zip object can be split, which allows parallelization.
523523/// A read-only zip object (no mutable producers) can be cloned.
524524///
@@ -546,7 +546,7 @@ impl<A, D: Dimension> NdProducer for RawArrayViewMut<A, D> {
546546/// .and(&b)
547547/// .and(&c)
548548/// .and(&d)
549- /// .apply (|w, &x, &y, &z| {
549+ /// .for_each (|w, &x, &y, &z| {
550550/// *w += x + y * z;
551551/// });
552552///
@@ -563,7 +563,7 @@ impl<A, D: Dimension> NdProducer for RawArrayViewMut<A, D> {
563563///
564564/// Zip::from(&mut totals)
565565/// .and(a.rows())
566- /// .apply (|totals, row| *totals = row.sum());
566+ /// .for_each (|totals, row| *totals = row.sum());
567567///
568568/// // Check the result against the built in `.sum_axis()` along axis 1.
569569/// assert_eq!(totals, a.sum_axis(Axis(1)));
@@ -692,21 +692,21 @@ impl<P, D> Zip<P, D>
692692where
693693 D : Dimension ,
694694{
695- fn apply_core < F , Acc > ( & mut self , acc : Acc , mut function : F ) -> FoldWhile < Acc >
695+ fn for_each_core < F , Acc > ( & mut self , acc : Acc , mut function : F ) -> FoldWhile < Acc >
696696 where
697697 F : FnMut ( Acc , P :: Item ) -> FoldWhile < Acc > ,
698698 P : ZippableTuple < Dim = D > ,
699699 {
700700 if self . dimension . ndim ( ) == 0 {
701701 function ( acc, unsafe { self . parts . as_ref ( self . parts . as_ptr ( ) ) } )
702702 } else if self . layout . is ( CORDER | FORDER ) {
703- self . apply_core_contiguous ( acc, function)
703+ self . for_each_core_contiguous ( acc, function)
704704 } else {
705- self . apply_core_strided ( acc, function)
705+ self . for_each_core_strided ( acc, function)
706706 }
707707 }
708708
709- fn apply_core_contiguous < F , Acc > ( & mut self , acc : Acc , mut function : F ) -> FoldWhile < Acc >
709+ fn for_each_core_contiguous < F , Acc > ( & mut self , acc : Acc , mut function : F ) -> FoldWhile < Acc >
710710 where
711711 F : FnMut ( Acc , P :: Item ) -> FoldWhile < Acc > ,
712712 P : ZippableTuple < Dim = D > ,
@@ -744,7 +744,7 @@ where
744744 }
745745
746746
747- fn apply_core_strided < F , Acc > ( & mut self , acc : Acc , function : F ) -> FoldWhile < Acc >
747+ fn for_each_core_strided < F , Acc > ( & mut self , acc : Acc , function : F ) -> FoldWhile < Acc >
748748 where
749749 F : FnMut ( Acc , P :: Item ) -> FoldWhile < Acc > ,
750750 P : ZippableTuple < Dim = D > ,
@@ -754,14 +754,14 @@ where
754754 panic ! ( "Unreachable: ndim == 0 is contiguous" )
755755 }
756756 if n == 1 || self . layout_tendency >= 0 {
757- self . apply_core_strided_c ( acc, function)
757+ self . for_each_core_strided_c ( acc, function)
758758 } else {
759- self . apply_core_strided_f ( acc, function)
759+ self . for_each_core_strided_f ( acc, function)
760760 }
761761 }
762762
763763 // Non-contiguous but preference for C - unroll over Axis(ndim - 1)
764- fn apply_core_strided_c < F , Acc > ( & mut self , mut acc : Acc , mut function : F ) -> FoldWhile < Acc >
764+ fn for_each_core_strided_c < F , Acc > ( & mut self , mut acc : Acc , mut function : F ) -> FoldWhile < Acc >
765765 where
766766 F : FnMut ( Acc , P :: Item ) -> FoldWhile < Acc > ,
767767 P : ZippableTuple < Dim = D > ,
@@ -785,7 +785,7 @@ where
785785 }
786786
787787 // Non-contiguous but preference for F - unroll over Axis(0)
788- fn apply_core_strided_f < F , Acc > ( & mut self , mut acc : Acc , mut function : F ) -> FoldWhile < Acc >
788+ fn for_each_core_strided_f < F , Acc > ( & mut self , mut acc : Acc , mut function : F ) -> FoldWhile < Acc >
789789 where
790790 F : FnMut ( Acc , P :: Item ) -> FoldWhile < Acc > ,
791791 P : ZippableTuple < Dim = D > ,
@@ -939,15 +939,24 @@ macro_rules! map_impl {
939939 {
940940 /// Apply a function to all elements of the input arrays,
941941 /// visiting elements in lock step.
942- pub fn apply <F >( mut self , mut function: F )
942+ pub fn for_each <F >( mut self , mut function: F )
943943 where F : FnMut ( $( $p:: Item ) ,* )
944944 {
945- self . apply_core ( ( ) , move |( ) , args| {
945+ self . for_each_core ( ( ) , move |( ) , args| {
946946 let ( $( $p, ) * ) = args;
947947 FoldWhile :: Continue ( function( $( $p) ,* ) )
948948 } ) ;
949949 }
950950
951+ /// Apply a function to all elements of the input arrays,
952+ /// visiting elements in lock step.
953+ #[ deprecated( note="Renamed to .for_each()" , since="0.15.0" ) ]
954+ pub fn apply<F >( self , function: F )
955+ where F : FnMut ( $( $p:: Item ) ,* )
956+ {
957+ self . for_each( function)
958+ }
959+
951960 /// Apply a fold function to all elements of the input arrays,
952961 /// visiting elements in lock step.
953962 ///
@@ -980,7 +989,7 @@ macro_rules! map_impl {
980989 where
981990 F : FnMut ( Acc , $( $p:: Item ) ,* ) -> Acc ,
982991 {
983- self . apply_core ( acc, move |acc, args| {
992+ self . for_each_core ( acc, move |acc, args| {
984993 let ( $( $p, ) * ) = args;
985994 FoldWhile :: Continue ( function( acc, $( $p) ,* ) )
986995 } ) . into_inner( )
@@ -993,7 +1002,7 @@ macro_rules! map_impl {
9931002 -> FoldWhile <Acc >
9941003 where F : FnMut ( Acc , $( $p:: Item ) ,* ) -> FoldWhile <Acc >
9951004 {
996- self . apply_core ( acc, move |acc, args| {
1005+ self . for_each_core ( acc, move |acc, args| {
9971006 let ( $( $p, ) * ) = args;
9981007 function( acc, $( $p) ,* )
9991008 } )
@@ -1015,7 +1024,7 @@ macro_rules! map_impl {
10151024 pub fn all<F >( mut self , mut predicate: F ) -> bool
10161025 where F : FnMut ( $( $p:: Item ) ,* ) -> bool
10171026 {
1018- !self . apply_core ( ( ) , move |_, args| {
1027+ !self . for_each_core ( ( ) , move |_, args| {
10191028 let ( $( $p, ) * ) = args;
10201029 if predicate( $( $p) ,* ) {
10211030 FoldWhile :: Continue ( ( ) )
@@ -1096,7 +1105,7 @@ macro_rules! map_impl {
10961105 Q :: Item : AssignElem <R >
10971106 {
10981107 self . and( into)
1099- . apply ( move |$( $p, ) * output_| {
1108+ . for_each ( move |$( $p, ) * output_| {
11001109 output_. assign_elem( f( $( $p ) ,* ) ) ;
11011110 } ) ;
11021111 }
@@ -1150,7 +1159,7 @@ macro_rules! map_impl {
11501159 // Apply the mapping function on this zip
11511160 // if we panic with unwinding; Partial will drop the written elements.
11521161 let partial_len = & mut partial. len;
1153- self . apply ( move |$( $p, ) * output_elem: * mut R | {
1162+ self . for_each ( move |$( $p, ) * output_elem: * mut R | {
11541163 output_elem. write( f( $( $p) ,* ) ) ;
11551164 if std:: mem:: needs_drop:: <R >( ) {
11561165 * partial_len += 1 ;
0 commit comments