@@ -534,7 +534,7 @@ unsafe impl<'a, A> DataMut for ViewRepr<&'a mut A> {}
534
534
535
535
/// Array representation trait.
536
536
///
537
- /// A representation that is a unique or shared owner of its data.
537
+ /// A representation which can be the owner of its data.
538
538
///
539
539
/// ***Internal trait, see `Data`.***
540
540
// The owned storage represents the ownership and allocation of the array's elements.
@@ -553,9 +553,13 @@ pub unsafe trait DataOwned: Data
553
553
fn new ( elements : Vec < Self :: Elem > ) -> Self ;
554
554
555
555
/// Converts the data representation to a shared (copy on write)
556
- /// representation, without any copying .
556
+ /// representation, cloning the array elements if necessary .
557
557
#[ 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 ;
559
563
}
560
564
561
565
/// Array representation trait.
@@ -578,9 +582,12 @@ unsafe impl<A> DataOwned for OwnedRepr<A>
578
582
OwnedRepr :: from ( elements)
579
583
}
580
584
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 ,
582
589
{
583
- OwnedArcRepr ( Arc :: new ( self ) )
590
+ ArcArray :: from ( self_ )
584
591
}
585
592
}
586
593
@@ -593,9 +600,12 @@ unsafe impl<A> DataOwned for OwnedArcRepr<A>
593
600
OwnedArcRepr ( Arc :: new ( OwnedRepr :: from ( elements) ) )
594
601
}
595
602
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 ,
597
607
{
598
- self
608
+ self_
599
609
}
600
610
}
601
611
@@ -720,6 +730,24 @@ unsafe impl<'a, A> Data for CowRepr<'a, A>
720
730
721
731
unsafe impl < ' a , A > DataMut for CowRepr < ' a , A > where A : Clone { }
722
732
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
+
723
751
/// Array representation trait.
724
752
///
725
753
/// The RawDataSubst trait maps the element type of array storage, while
0 commit comments