From: Nicolas Patry Date: Fri, 8 Aug 2025 12:23:12 +0000 (+0200) Subject: Fixing clippy in 1.89 (#644) X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=5eecd2917c5efe77c2c3b065ad07afcbcd057cba;p=safetensors.git Fixing clippy in 1.89 (#644) --- diff --git a/bindings/python/src/lib.rs b/bindings/python/src/lib.rs index 36f784b..c039d6e 100644 --- a/bindings/python/src/lib.rs +++ b/bindings/python/src/lib.rs @@ -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] { diff --git a/safetensors/src/tensor.rs b/safetensors/src/tensor.rs index 0a4edf3..c9ee214 100644 --- a/safetensors/src/tensor.rs +++ b/safetensors/src/tensor.rs @@ -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 = 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() }