We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 50573f8 commit 2af780fCopy full SHA for 2af780f
src/impl_methods.rs
@@ -1331,15 +1331,15 @@ where
1331
if self.is_standard_layout() {
1332
CowArray::from(self.view())
1333
} else {
1334
- let v: Vec<A> = self.iter().cloned().collect();
+ let v = crate::iterators::to_vec_mapped(self.iter(), A::clone);
1335
let dim = self.dim.clone();
1336
- assert_eq!(v.len(), dim.size());
1337
- let owned_array: Array<A, D> = unsafe {
+ debug_assert_eq!(v.len(), dim.size());
+
1338
+ unsafe {
1339
// Safe because the shape and element type are from the existing array
1340
// and the strides are the default strides.
- Array::from_shape_vec_unchecked(dim, v)
1341
- };
1342
- CowArray::from(owned_array)
+ CowArray::from(Array::from_shape_vec_unchecked(dim, v))
+ }
1343
}
1344
1345
0 commit comments