@@ -1157,7 +1157,10 @@ fn array0_into_scalar()
11571157 // With this kind of setup, the `Array`'s pointer is not the same as the
11581158 // underlying `Vec`'s pointer.
11591159 let a: Array0 < i32 > = array ! [ 4 , 5 , 6 , 7 ] . index_axis_move ( Axis ( 0 ) , 2 ) ;
1160- assert_ne ! ( a. as_ptr( ) , a. into_raw_vec( ) . 0 . as_ptr( ) ) ;
1160+ let a_ptr = a. as_ptr ( ) ;
1161+ let ( raw_vec, offset) = a. into_raw_vec_and_offset ( ) ;
1162+ assert_ne ! ( a_ptr, raw_vec. as_ptr( ) ) ;
1163+ assert_eq ! ( offset, Some ( 2 ) ) ;
11611164 // `.into_scalar()` should still work correctly.
11621165 let a: Array0 < i32 > = array ! [ 4 , 5 , 6 , 7 ] . index_axis_move ( Axis ( 0 ) , 2 ) ;
11631166 assert_eq ! ( a. into_scalar( ) , 6 ) ;
@@ -1173,7 +1176,10 @@ fn array_view0_into_scalar()
11731176 // With this kind of setup, the `Array`'s pointer is not the same as the
11741177 // underlying `Vec`'s pointer.
11751178 let a: Array0 < i32 > = array ! [ 4 , 5 , 6 , 7 ] . index_axis_move ( Axis ( 0 ) , 2 ) ;
1176- assert_ne ! ( a. as_ptr( ) , a. into_raw_vec( ) . 0 . as_ptr( ) ) ;
1179+ let a_ptr = a. as_ptr ( ) ;
1180+ let ( raw_vec, offset) = a. into_raw_vec_and_offset ( ) ;
1181+ assert_ne ! ( a_ptr, raw_vec. as_ptr( ) ) ;
1182+ assert_eq ! ( offset, Some ( 2 ) ) ;
11771183 // `.into_scalar()` should still work correctly.
11781184 let a: Array0 < i32 > = array ! [ 4 , 5 , 6 , 7 ] . index_axis_move ( Axis ( 0 ) , 2 ) ;
11791185 assert_eq ! ( a. view( ) . into_scalar( ) , & 6 ) ;
@@ -1189,7 +1195,7 @@ fn array_view_mut0_into_scalar()
11891195 // With this kind of setup, the `Array`'s pointer is not the same as the
11901196 // underlying `Vec`'s pointer.
11911197 let a: Array0 < i32 > = array ! [ 4 , 5 , 6 , 7 ] . index_axis_move ( Axis ( 0 ) , 2 ) ;
1192- assert_ne ! ( a. as_ptr( ) , a. into_raw_vec ( ) . 0 . as_ptr( ) ) ;
1198+ assert_ne ! ( a. as_ptr( ) , a. into_raw_vec_and_offset ( ) . 0 . as_ptr( ) ) ;
11931199 // `.into_scalar()` should still work correctly.
11941200 let mut a: Array0 < i32 > = array ! [ 4 , 5 , 6 , 7 ] . index_axis_move ( Axis ( 0 ) , 2 ) ;
11951201 assert_eq ! ( a. view_mut( ) . into_scalar( ) , & 6 ) ;
@@ -1199,6 +1205,16 @@ fn array_view_mut0_into_scalar()
11991205 assert_eq ! ( a. view_mut( ) . into_scalar( ) , & ( ) ) ;
12001206}
12011207
1208+ #[ test]
1209+ fn array1_into_raw_vec ( )
1210+ {
1211+ let data = vec ! [ 4 , 5 , 6 , 7 ] ;
1212+ let array = Array :: from ( data. clone ( ) ) ;
1213+ let ( raw_vec, offset) = array. into_raw_vec_and_offset ( ) ;
1214+ assert_eq ! ( data, raw_vec) ;
1215+ assert_eq ! ( offset, Some ( 0 ) ) ;
1216+ }
1217+
12021218#[ test]
12031219fn owned_array1 ( )
12041220{
0 commit comments