@@ -534,7 +534,7 @@ unsafe impl<'a, A> DataMut for ViewRepr<&'a mut A> {}
534534
535535/// Array representation trait.
536536///
537- /// A representation that is a unique or shared owner of its data.
537+ /// A representation which can be the owner of its data.
538538///
539539/// ***Internal trait, see `Data`.***
540540// The owned storage represents the ownership and allocation of the array's elements.
@@ -553,9 +553,13 @@ pub unsafe trait DataOwned: Data
553553 fn new ( elements : Vec < Self :: Elem > ) -> Self ;
554554
555555 /// Converts the data representation to a shared (copy on write)
556- /// representation, without any copying .
556+ /// representation, cloning the array elements if necessary .
557557 #[ doc( hidden) ]
558- fn into_shared ( self ) -> OwnedArcRepr < Self :: Elem > ;
558+ #[ allow( clippy:: wrong_self_convention) ]
559+ fn into_shared < D > ( self_ : ArrayBase < Self , D > ) -> ArcArray < Self :: Elem , D >
560+ where
561+ Self :: Elem : Clone ,
562+ D : Dimension ;
559563}
560564
561565/// Array representation trait.
@@ -578,9 +582,12 @@ unsafe impl<A> DataOwned for OwnedRepr<A>
578582 OwnedRepr :: from ( elements)
579583 }
580584
581- fn into_shared ( self ) -> OwnedArcRepr < A >
585+ fn into_shared < D > ( self_ : ArrayBase < Self , D > ) -> ArcArray < A , D >
586+ where
587+ A : Clone ,
588+ D : Dimension ,
582589 {
583- OwnedArcRepr ( Arc :: new ( self ) )
590+ ArcArray :: from ( self_ )
584591 }
585592}
586593
@@ -593,9 +600,12 @@ unsafe impl<A> DataOwned for OwnedArcRepr<A>
593600 OwnedArcRepr ( Arc :: new ( OwnedRepr :: from ( elements) ) )
594601 }
595602
596- fn into_shared ( self ) -> OwnedArcRepr < A >
603+ fn into_shared < D > ( self_ : ArrayBase < Self , D > ) -> ArcArray < A , D >
604+ where
605+ A : Clone ,
606+ D : Dimension ,
597607 {
598- self
608+ self_
599609 }
600610}
601611
@@ -720,6 +730,24 @@ unsafe impl<'a, A> Data for CowRepr<'a, A>
720730
721731unsafe impl < ' a , A > DataMut for CowRepr < ' a , A > where A : Clone { }
722732
733+ unsafe impl < ' a , A > DataOwned for CowRepr < ' a , A >
734+ {
735+ type MaybeUninit = CowRepr < ' a , MaybeUninit < A > > ;
736+
737+ fn new ( elements : Vec < A > ) -> Self
738+ {
739+ CowRepr :: Owned ( OwnedRepr :: new ( elements) )
740+ }
741+
742+ fn into_shared < D > ( self_ : ArrayBase < Self , D > ) -> ArcArray < A , D >
743+ where
744+ A : Clone ,
745+ D : Dimension ,
746+ {
747+ self_. into_owned ( ) . into_shared ( )
748+ }
749+ }
750+
723751/// Array representation trait.
724752///
725753/// The RawDataSubst trait maps the element type of array storage, while
0 commit comments