@@ -195,7 +195,7 @@ struct DLTensorDebug<'a>(&'a sys::DLTensor);
195195impl std:: fmt:: Debug for DLTensorDebug < ' _ > {
196196 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
197197 let tensor_ref = unsafe {
198- DLPackTensorRef :: from_raw ( self . 0 . clone ( ) )
198+ DLPackTensorRef :: from_raw ( * self . 0 )
199199 } ;
200200 debug_tensor ( & tensor_ref, f, "DLTensor" )
201201 }
@@ -300,7 +300,7 @@ impl DLPackTensor {
300300 pub fn as_ref ( & self ) -> DLPackTensorRef < ' _ > {
301301 unsafe {
302302 // SAFETY: we are constaining the returned reference lifetime
303- DLPackTensorRef :: from_raw ( self . raw . as_ref ( ) . dl_tensor . clone ( ) )
303+ DLPackTensorRef :: from_raw ( self . raw . as_ref ( ) . dl_tensor )
304304 }
305305 }
306306
@@ -320,7 +320,7 @@ impl DLPackTensor {
320320 // SAFETY: we are constraining the returned reference lifetime
321321 // the caller must ensure that the uniqueness check doesn't apply
322322 // i.e. they're fine mutating an ArcArray with refcount > 1
323- DLPackTensorRefMut :: from_raw ( self . raw . as_ref ( ) . dl_tensor . clone ( ) )
323+ DLPackTensorRefMut :: from_raw ( self . raw . as_ref ( ) . dl_tensor )
324324 }
325325 }
326326
@@ -434,6 +434,7 @@ impl DLPackTensor {
434434
435435/// A reference to a DLPack tensor, with data borrowed from some owner,
436436/// potentially in another language.
437+ #[ derive( Clone , Copy ) ]
437438pub struct DLPackTensorRef < ' a > {
438439 pub raw : sys:: DLTensor ,
439440 phantom : std:: marker:: PhantomData < & ' a [ u8 ] > ,
@@ -519,7 +520,7 @@ impl<'a> DLPackTensorRef<'a> {
519520/// potentially in another language.
520521pub struct DLPackTensorRefMut < ' a > {
521522 raw : sys:: DLTensor ,
522- phantom : std:: marker:: PhantomData < & ' a [ u8 ] > ,
523+ phantom : std:: marker:: PhantomData < & ' a mut [ u8 ] > ,
523524}
524525
525526impl std:: fmt:: Debug for DLPackTensorRefMut < ' _ > {
@@ -548,7 +549,7 @@ impl<'a> DLPackTensorRefMut<'a> {
548549 pub fn as_ref ( & self ) -> DLPackTensorRef < ' _ > {
549550 unsafe {
550551 // SAFETY: we are constaining the returned reference lifetime
551- DLPackTensorRef :: from_raw ( self . raw . clone ( ) )
552+ DLPackTensorRef :: from_raw ( self . raw )
552553 }
553554 }
554555
@@ -624,10 +625,12 @@ pub mod sync;
624625
625626/// Small wrapper type to mark a tensor as read-only when there is a choice
626627/// between a read-only and a read-write implementation.
628+ #[ derive( Debug , Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
627629pub struct ReadOnly < T > ( pub T ) ;
628630
629631/// Small wrapper type to mark a tensor as read-write when there is a choice
630632/// between a read-only and a read-write implementation.
633+ #[ derive( Debug , Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
631634pub struct ReadWrite < T > ( pub T ) ;
632635
633636
0 commit comments