@@ -41,14 +41,14 @@ fn move_into_copy() {
4141 let a = arr2 ( & [ [ 1. , 2. ] , [ 3. , 4. ] ] ) ;
4242 let acopy = a. clone ( ) ;
4343 let mut b = Array :: uninit ( a. dim ( ) ) ;
44- a. move_into ( b. view_mut ( ) ) ;
44+ a. move_into_uninit ( b. view_mut ( ) ) ;
4545 let b = unsafe { b. assume_init ( ) } ;
4646 assert_eq ! ( acopy, b) ;
4747
4848 let a = arr2 ( & [ [ 1. , 2. ] , [ 3. , 4. ] ] ) . reversed_axes ( ) ;
4949 let acopy = a. clone ( ) ;
5050 let mut b = Array :: uninit ( a. dim ( ) ) ;
51- a. move_into ( b. view_mut ( ) ) ;
51+ a. move_into_uninit ( b. view_mut ( ) ) ;
5252 let b = unsafe { b. assume_init ( ) } ;
5353 assert_eq ! ( acopy, b) ;
5454}
@@ -74,7 +74,7 @@ fn move_into_owned() {
7474
7575 let acopy = a. clone ( ) ;
7676 let mut b = Array :: uninit ( a. dim ( ) ) ;
77- a. move_into ( b. view_mut ( ) ) ;
77+ a. move_into_uninit ( b. view_mut ( ) ) ;
7878 let b = unsafe { b. assume_init ( ) } ;
7979
8080 assert_eq ! ( acopy, b) ;
@@ -85,7 +85,7 @@ fn move_into_owned() {
8585
8686#[ test]
8787fn move_into_slicing ( ) {
88- // Count correct number of drops when using move_into and discontiguous arrays (with holes).
88+ // Count correct number of drops when using move_into_uninit and discontiguous arrays (with holes).
8989 for & use_f_order in & [ false , true ] {
9090 for & invert_axis in & [ 0b00 , 0b01 , 0b10 , 0b11 ] { // bitmask for axis to invert
9191 let counter = DropCounter :: default ( ) ;
@@ -102,7 +102,7 @@ fn move_into_slicing() {
102102 }
103103
104104 let mut b = Array :: uninit ( a. dim ( ) ) ;
105- a. move_into ( b. view_mut ( ) ) ;
105+ a. move_into_uninit ( b. view_mut ( ) ) ;
106106 let b = unsafe { b. assume_init ( ) } ;
107107
108108 let total = m * n;
@@ -118,7 +118,7 @@ fn move_into_slicing() {
118118
119119#[ test]
120120fn move_into_diag ( ) {
121- // Count correct number of drops when using move_into and discontiguous arrays (with holes).
121+ // Count correct number of drops when using move_into_uninit and discontiguous arrays (with holes).
122122 for & use_f_order in & [ false , true ] {
123123 let counter = DropCounter :: default ( ) ;
124124 {
@@ -128,7 +128,7 @@ fn move_into_diag() {
128128 let a = a. into_diag ( ) ;
129129
130130 let mut b = Array :: uninit ( a. dim ( ) ) ;
131- a. move_into ( b. view_mut ( ) ) ;
131+ a. move_into_uninit ( b. view_mut ( ) ) ;
132132 let b = unsafe { b. assume_init ( ) } ;
133133
134134 let total = m * n;
@@ -143,7 +143,7 @@ fn move_into_diag() {
143143
144144#[ test]
145145fn move_into_0dim ( ) {
146- // Count correct number of drops when using move_into and discontiguous arrays (with holes).
146+ // Count correct number of drops when using move_into_uninit and discontiguous arrays (with holes).
147147 for & use_f_order in & [ false , true ] {
148148 let counter = DropCounter :: default ( ) ;
149149 {
@@ -155,7 +155,7 @@ fn move_into_0dim() {
155155
156156 assert_eq ! ( a. ndim( ) , 0 ) ;
157157 let mut b = Array :: uninit ( a. dim ( ) ) ;
158- a. move_into ( b. view_mut ( ) ) ;
158+ a. move_into_uninit ( b. view_mut ( ) ) ;
159159 let b = unsafe { b. assume_init ( ) } ;
160160
161161 let total = m * n;
@@ -170,7 +170,7 @@ fn move_into_0dim() {
170170
171171#[ test]
172172fn move_into_empty ( ) {
173- // Count correct number of drops when using move_into and discontiguous arrays (with holes).
173+ // Count correct number of drops when using move_into_uninit and discontiguous arrays (with holes).
174174 for & use_f_order in & [ false , true ] {
175175 let counter = DropCounter :: default ( ) ;
176176 {
@@ -181,7 +181,7 @@ fn move_into_empty() {
181181 let a = a. slice_move ( s ! [ ..0 , 1 ..1 ] ) ;
182182 assert ! ( a. is_empty( ) ) ;
183183 let mut b = Array :: uninit ( a. dim ( ) ) ;
184- a. move_into ( b. view_mut ( ) ) ;
184+ a. move_into_uninit ( b. view_mut ( ) ) ;
185185 let b = unsafe { b. assume_init ( ) } ;
186186
187187 let total = m * n;
@@ -194,6 +194,35 @@ fn move_into_empty() {
194194 }
195195}
196196
197+ #[ test]
198+ fn move_into ( ) {
199+ // Test various memory layouts and holes while moving String elements with move_into
200+ for & use_f_order in & [ false , true ] {
201+ for & invert_axis in & [ 0b00 , 0b01 , 0b10 , 0b11 ] { // bitmask for axis to invert
202+ for & slice in & [ false , true ] {
203+ let mut a = Array :: from_shape_fn ( ( 5 , 4 ) . set_f ( use_f_order) ,
204+ |idx| format ! ( "{:?}" , idx) ) ;
205+ if slice {
206+ a. slice_collapse ( s ! [ 1 ..-1 , ..; 2 ] ) ;
207+ }
208+
209+ if invert_axis & 0b01 != 0 {
210+ a. invert_axis ( Axis ( 0 ) ) ;
211+ }
212+ if invert_axis & 0b10 != 0 {
213+ a. invert_axis ( Axis ( 1 ) ) ;
214+ }
215+
216+ let acopy = a. clone ( ) ;
217+ let mut b = Array :: default ( a. dim ( ) . set_f ( !use_f_order ^ !slice) ) ;
218+ a. move_into ( & mut b) ;
219+
220+ assert_eq ! ( acopy, b) ;
221+ }
222+ }
223+ }
224+ }
225+
197226
198227/// This counter can create elements, and then count and verify
199228/// the number of which have actually been dropped again.
0 commit comments