File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -1331,15 +1331,15 @@ where
13311331 if self . is_standard_layout ( ) {
13321332 CowArray :: from ( self . view ( ) )
13331333 } else {
1334- let v: Vec < A > = self . iter ( ) . cloned ( ) . collect ( ) ;
1334+ let v = crate :: iterators :: to_vec_mapped ( self . iter ( ) , A :: clone ) ;
13351335 let dim = self . dim . clone ( ) ;
1336- assert_eq ! ( v. len( ) , dim. size( ) ) ;
1337- let owned_array: Array < A , D > = unsafe {
1336+ debug_assert_eq ! ( v. len( ) , dim. size( ) ) ;
1337+
1338+ unsafe {
13381339 // Safe because the shape and element type are from the existing array
13391340 // and the strides are the default strides.
1340- Array :: from_shape_vec_unchecked ( dim, v)
1341- } ;
1342- CowArray :: from ( owned_array)
1341+ CowArray :: from ( Array :: from_shape_vec_unchecked ( dim, v) )
1342+ }
13431343 }
13441344 }
13451345
You can’t perform that action at this time.
0 commit comments