]> khamidou — GitHub mirrors - safetensors.git/commitdiff
Fixing clippy in 1.89 (#644)
authorNicolas Patry <patry.nicolas@protonmail.com>
Fri, 8 Aug 2025 12:23:12 +0000 (14:23 +0200)
committerGitHub <noreply@github.com>
Fri, 8 Aug 2025 12:23:12 +0000 (14:23 +0200)
bindings/python/src/lib.rs
safetensors/src/tensor.rs

index 36f784b4f76a49cea4c94df78f762fcc8b8b331b..c039d6e440319eb99f43a84da7f2b50596f05840 100644 (file)
@@ -33,7 +33,7 @@ struct PyView<'a> {
 }
 
 impl View for &PyView<'_> {
-    fn data(&self) -> std::borrow::Cow<[u8]> {
+    fn data(&self) -> std::borrow::Cow<'_, [u8]> {
         Cow::Borrowed(self.data.as_bytes())
     }
     fn shape(&self) -> &[usize] {
index 0a4edf3d3666710c12cd1f74cde88b4e4f2b522a..c9ee214315b7e2edd94534922584605465062e2c 100644 (file)
@@ -142,7 +142,7 @@ struct PreparedData {
 ///    fn shape(&self) -> &[usize]{
 ///         &self.shape
 ///    }
-///    fn data(&self) -> Cow<[u8]>{
+///    fn data(&self) -> Cow<'_, [u8]>{
 ///        (&self.data).into()
 ///    }
 ///    fn data_len(&self) -> usize{
@@ -166,7 +166,7 @@ struct PreparedData {
 ///    fn shape(&self) -> &[usize]{
 ///         &self.shape
 ///    }
-///    fn data(&self) -> Cow<[u8]>{
+///    fn data(&self) -> Cow<'_, [u8]>{
 ///        self.data.into()
 ///    }
 ///    fn data_len(&self) -> usize{
@@ -193,7 +193,7 @@ struct PreparedData {
 ///    fn shape(&self) -> &[usize]{
 ///         &self.shape
 ///    }
-///    fn data(&self) -> Cow<[u8]>{
+///    fn data(&self) -> Cow<'_, [u8]>{
 ///        // This copies data from GPU to CPU.
 ///        let data: Vec<u8> = self.data.to_vec();
 ///        data.into()
@@ -211,7 +211,7 @@ pub trait View {
     /// The shape of the tensor
     fn shape(&self) -> &[usize];
     /// The data of the tensor
-    fn data(&self) -> Cow<[u8]>;
+    fn data(&self) -> Cow<'_, [u8]>;
     /// The length of the data, in bytes.
     /// This is necessary as this might be faster to get than `data().len()`
     /// for instance for tensors residing in GPU.
@@ -678,7 +678,7 @@ impl View for &TensorView<'_> {
         &self.shape
     }
 
-    fn data(&self) -> Cow<[u8]> {
+    fn data(&self) -> Cow<'_, [u8]> {
         self.data.into()
     }
 
@@ -696,7 +696,7 @@ impl View for TensorView<'_> {
         &self.shape
     }
 
-    fn data(&self) -> Cow<[u8]> {
+    fn data(&self) -> Cow<'_, [u8]> {
         self.data.into()
     }