clippy fix: the borrowed expression implements the required traits

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

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
This commit is contained in:
Lukas Wagner 2023-08-08 10:01:39 +02:00 committed by Wolfgang Bumiller
parent b7a64cd4a2
commit de6337ae6d
7 changed files with 15 additions and 16 deletions

View File

@ -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)));
}

View File

@ -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 {

View File

@ -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)?;

View File

@ -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)),
}
}
}

View File

@ -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('"')?;

View File

@ -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()))
})
}

View File

@ -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!({