File tree Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -96,6 +96,18 @@ pub unsafe trait Data: RawData {
9696 where
9797 Self :: Elem : Clone ,
9898 D : Dimension ;
99+
100+ /// Return a shared ownership (copy on write) array based on the existing one,
101+ /// cloning elements if necessary.
102+ #[ doc( hidden) ]
103+ fn to_shared < D > ( self_ : & ArrayBase < Self , D > ) -> ArrayBase < OwnedArcRepr < Self :: Elem > , D >
104+ where
105+ Self :: Elem : Clone ,
106+ D : Dimension ,
107+ {
108+ // clone to shared
109+ self_. to_owned ( ) . into_shared ( )
110+ }
99111}
100112
101113/// Array representation trait.
@@ -238,6 +250,15 @@ unsafe impl<A> Data for OwnedArcRepr<A> {
238250 strides : self_. strides ,
239251 }
240252 }
253+
254+ fn to_shared < D > ( self_ : & ArrayBase < Self , D > ) -> ArrayBase < OwnedArcRepr < Self :: Elem > , D >
255+ where
256+ Self :: Elem : Clone ,
257+ D : Dimension ,
258+ {
259+ // to shared using clone of OwnedArcRepr without clone of raw data.
260+ self_. clone ( )
261+ }
241262}
242263
243264unsafe impl < A > DataMut for OwnedArcRepr < A > where A : Clone { }
Original file line number Diff line number Diff line change @@ -215,14 +215,14 @@ where
215215 }
216216 }
217217
218- /// Return a shared ownership (copy on write) array.
218+ /// Return a shared ownership (copy on write) array, cloning the array
219+ /// elements if necessary.
219220 pub fn to_shared ( & self ) -> ArcArray < A , D >
220221 where
221222 A : Clone ,
222223 S : Data ,
223224 {
224- // FIXME: Avoid copying if it’s already an ArcArray.
225- self . to_owned ( ) . into_shared ( )
225+ S :: to_shared ( self )
226226 }
227227
228228 /// Turn the array into a uniquely owned array, cloning the array elements
You can’t perform that action at this time.
0 commit comments