public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox 01/15] clippy fix: the borrowed expression implements the required traits
@ 2023-08-08  8:01 Lukas Wagner
  2023-08-08  8:01 ` [pbs-devel] [PATCH proxmox 02/15] clippy fix: casting to the same type is unnecessary Lukas Wagner
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: Lukas Wagner @ 2023-08-08  8:01 UTC (permalink / raw)
  To: pbs-devel

See: https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
 proxmox-apt/src/repositories/file.rs       |  2 +-
 proxmox-apt/src/repositories/repository.rs |  2 +-
 proxmox-openid/src/auth_state.rs           |  2 +-
 proxmox-rest-server/src/worker_task.rs     | 10 +++++-----
 proxmox-schema/src/ser/mod.rs              |  4 ++--
 proxmox-serde/src/lib.rs                   |  9 ++++-----
 proxmox-subscription/src/check.rs          |  2 +-
 7 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/proxmox-apt/src/repositories/file.rs b/proxmox-apt/src/repositories/file.rs
index b4c6b08..bfd7836 100644
--- a/proxmox-apt/src/repositories/file.rs
+++ b/proxmox-apt/src/repositories/file.rs
@@ -293,7 +293,7 @@ impl APTRepositoryFile {
         }
 
         if self.repositories.is_empty() {
-            return std::fs::remove_file(&path)
+            return std::fs::remove_file(path)
                 .map_err(|err| self.err(format_err!("unable to remove file - {}", err)));
         }
 
diff --git a/proxmox-apt/src/repositories/repository.rs b/proxmox-apt/src/repositories/repository.rs
index c2df2c7..0b04802 100644
--- a/proxmox-apt/src/repositories/repository.rs
+++ b/proxmox-apt/src/repositories/repository.rs
@@ -414,7 +414,7 @@ fn uri_to_filename(uri: &str) -> String {
         if *b <= 0x20 || *b >= 0x7F || encode_chars.contains(*b as char) {
             let mut hex = [0u8; 2];
             // unwrap: we're hex-encoding a single byte into a 2-byte slice
-            hex::encode_to_slice(&[*b], &mut hex).unwrap();
+            hex::encode_to_slice([*b], &mut hex).unwrap();
             let hex = unsafe { std::str::from_utf8_unchecked(&hex) };
             encoded = format!("{}%{}", encoded, hex);
         } else {
diff --git a/proxmox-openid/src/auth_state.rs b/proxmox-openid/src/auth_state.rs
index 8d940ec..f2a299a 100644
--- a/proxmox-openid/src/auth_state.rs
+++ b/proxmox-openid/src/auth_state.rs
@@ -97,7 +97,7 @@ pub fn store_auth_state(
         bail!("too many pending openid auth request for realm {}", realm);
     }
 
-    data.push(serde_json::to_value(&auth_state)?);
+    data.push(serde_json::to_value(auth_state)?);
 
     replace_auth_state(&path, &data)?;
 
diff --git a/proxmox-rest-server/src/worker_task.rs b/proxmox-rest-server/src/worker_task.rs
index 6263ce7..54b6bc2 100644
--- a/proxmox-rest-server/src/worker_task.rs
+++ b/proxmox-rest-server/src/worker_task.rs
@@ -1023,11 +1023,11 @@ impl WorkerTaskContext for WorkerTask {
 
     fn log(&self, level: log::Level, message: &std::fmt::Arguments) {
         match level {
-            log::Level::Error => self.log_warning(&message.to_string()),
-            log::Level::Warn => self.log_warning(&message.to_string()),
-            log::Level::Info => self.log_message(&message.to_string()),
-            log::Level::Debug => self.log_message(&format!("DEBUG: {}", message)),
-            log::Level::Trace => self.log_message(&format!("TRACE: {}", message)),
+            log::Level::Error => self.log_warning(message.to_string()),
+            log::Level::Warn => self.log_warning(message.to_string()),
+            log::Level::Info => self.log_message(message.to_string()),
+            log::Level::Debug => self.log_message(format!("DEBUG: {}", message)),
+            log::Level::Trace => self.log_message(format!("TRACE: {}", message)),
         }
     }
 }
diff --git a/proxmox-schema/src/ser/mod.rs b/proxmox-schema/src/ser/mod.rs
index bcf473d..3dad6d6 100644
--- a/proxmox-schema/src/ser/mod.rs
+++ b/proxmox-schema/src/ser/mod.rs
@@ -448,7 +448,7 @@ impl<T: fmt::Write> Serializer for ElementSerializer<T> {
     }
 
     fn serialize_str(mut self, v: &str) -> Result<Self::Ok, Error> {
-        if v.contains(&['"', '\\', '\n']) {
+        if v.contains(['"', '\\', '\n']) {
             self.inner.write_char('"')?;
             crate::property_string::quote(v, &mut self.inner)?;
             self.inner.write_char('"')?;
@@ -643,7 +643,7 @@ impl<T: fmt::Write> ElementSerializeSeq<T> {
 
     fn finish(mut self) -> Result<T, Error> {
         let value = self.inner.finish()?;
-        if value.contains(&[',', ';', ' ', '"', '\\', '\n']) {
+        if value.contains([',', ';', ' ', '"', '\\', '\n']) {
             self.output.write_char('"')?;
             crate::property_string::quote(&value, &mut self.output)?;
             self.output.write_char('"')?;
diff --git a/proxmox-serde/src/lib.rs b/proxmox-serde/src/lib.rs
index e1dc16a..2f1ccca 100644
--- a/proxmox-serde/src/lib.rs
+++ b/proxmox-serde/src/lib.rs
@@ -86,9 +86,8 @@ pub mod bytes_as_base64 {
         D: Deserializer<'de>,
     {
         use serde::de::Error;
-        String::deserialize(deserializer).and_then(|string| {
-            base64::decode(&string).map_err(|err| Error::custom(err.to_string()))
-        })
+        String::deserialize(deserializer)
+            .and_then(|string| base64::decode(string).map_err(|err| Error::custom(err.to_string())))
     }
 }
 
@@ -125,7 +124,7 @@ pub mod string_as_base64 {
     fn finish_deserializing<'de, D: Deserializer<'de>>(string: String) -> Result<String, D::Error> {
         use serde::de::Error;
 
-        let bytes = base64::decode(&string).map_err(|err| {
+        let bytes = base64::decode(string).map_err(|err| {
             let msg = format!("base64 decode: {}", err);
             Error::custom(msg)
         })?;
@@ -219,7 +218,7 @@ pub mod bytes_as_base64url_nopad {
     {
         use serde::de::Error;
         String::deserialize(deserializer).and_then(|string| {
-            base64::decode_config(&string, base64::URL_SAFE_NO_PAD)
+            base64::decode_config(string, base64::URL_SAFE_NO_PAD)
                 .map_err(|err| Error::custom(err.to_string()))
         })
     }
diff --git a/proxmox-subscription/src/check.rs b/proxmox-subscription/src/check.rs
index 3838e9c..9d074ea 100644
--- a/proxmox-subscription/src/check.rs
+++ b/proxmox-subscription/src/check.rs
@@ -25,7 +25,7 @@ fn register_subscription<C: HttpClient<String, String>>(
     client: C,
 ) -> Result<(String, String), Error> {
     // WHCMS sample code feeds the key into this, but it's just a challenge, so keep it simple
-    let rand = hex::encode(&proxmox_sys::linux::random_data(16)?);
+    let rand = hex::encode(proxmox_sys::linux::random_data(16)?);
     let challenge = format!("{}{}", checktime, rand);
 
     let params = json!({
-- 
2.39.2





^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2023-08-08  9:34 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-08  8:01 [pbs-devel] [PATCH proxmox 01/15] clippy fix: the borrowed expression implements the required traits Lukas Wagner
2023-08-08  8:01 ` [pbs-devel] [PATCH proxmox 02/15] clippy fix: casting to the same type is unnecessary Lukas Wagner
2023-08-08  8:01 ` [pbs-devel] [PATCH proxmox 03/15] clippy fix: calls to `drop` with a value that implements `Copy` Lukas Wagner
2023-08-08  8:01 ` [pbs-devel] [PATCH proxmox 04/15] clippy fix: needless borrow Lukas Wagner
2023-08-08  8:01 ` [pbs-devel] [PATCH proxmox 05/15] clippy fix: unneeded `return` statement Lukas Wagner
2023-08-08  8:01 ` [pbs-devel] [PATCH proxmox 06/15] clippy fix: redundant closure Lukas Wagner
2023-08-08  8:01 ` [pbs-devel] [PATCH proxmox 07/15] clippy fix: this (Default) `impl` can be derived Lukas Wagner
2023-08-08  8:01 ` [pbs-devel] [PATCH proxmox 08/15] clippy fix: you should consider adding a `Default` implementation Lukas Wagner
2023-08-08  8:01 ` [pbs-devel] [PATCH proxmox 09/15] clippy fix: unnecessary use of `to_string` Lukas Wagner
2023-08-08  8:01 ` [pbs-devel] [PATCH proxmox 10/15] clippy fix: binary comparison to literal `Option::None` Lukas Wagner
2023-08-08  8:01 ` [pbs-devel] [PATCH proxmox 11/15] clippy fix: warning: this let-binding has unit value Lukas Wagner
2023-08-08  8:01 ` [pbs-devel] [PATCH proxmox 12/15] clippy fix: useless use of `format!` Lukas Wagner
2023-08-08  8:01 ` [pbs-devel] [PATCH proxmox 13/15] clippy fix: the following explicit lifetimes could be elided Lukas Wagner
2023-08-08  8:01 ` [pbs-devel] [PATCH proxmox 14/15] clippy fix: complex type definitions Lukas Wagner
2023-08-08  8:01 ` [pbs-devel] [PATCH proxmox 15/15] clippy fix: deref on an immutable reference Lukas Wagner
2023-08-08  9:33 ` [pbs-devel] partially-applied: [PATCH proxmox 01/15] clippy fix: the borrowed expression implements the required traits Wolfgang Bumiller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal