@@ -29,6 +29,7 @@ use crate::indices;
2929#[ cfg( feature = "std" ) ]
3030use crate :: iterators:: to_vec;
3131use crate :: iterators:: to_vec_mapped;
32+ use crate :: iterators:: TrustedIterator ;
3233use crate :: StrideShape ;
3334#[ cfg( feature = "std" ) ]
3435use crate :: { geomspace, linspace, logspace} ;
@@ -495,6 +496,27 @@ where
495496 ArrayBase :: from_data_ptr ( DataOwned :: new ( v) , ptr) . with_strides_dim ( strides, dim)
496497 }
497498
499+ /// Creates an array from an iterator, mapped by `map` and interpret it according to the
500+ /// provided shape and strides.
501+ ///
502+ /// # Safety
503+ ///
504+ /// See from_shape_vec_unchecked
505+ pub ( crate ) unsafe fn from_shape_trusted_iter_unchecked < Sh , I , F > ( shape : Sh , iter : I , map : F )
506+ -> Self
507+ where
508+ Sh : Into < StrideShape < D > > ,
509+ I : TrustedIterator + ExactSizeIterator ,
510+ F : FnMut ( I :: Item ) -> A ,
511+ {
512+ let shape = shape. into ( ) ;
513+ let dim = shape. dim ;
514+ let strides = shape. strides . strides_for_dim ( & dim) ;
515+ let v = to_vec_mapped ( iter, map) ;
516+ Self :: from_vec_dim_stride_unchecked ( dim, strides, v)
517+ }
518+
519+
498520 /// Create an array with uninitalized elements, shape `shape`.
499521 ///
500522 /// The uninitialized elements of type `A` are represented by the type `MaybeUninit<A>`,
0 commit comments