remove needless borrows
Fixes the following clippy warnings: warning: the borrowed expression implements the required traits --> proxmox-tfa/src/api/recovery.rs:86:24 | 86 | Ok(hex::encode(&hmac)) | ^^^^^ help: change this to: `hmac` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrows_for_generic_args and warning: this expression creates a reference which is immediately dereferenced by the compiler --> proxmox-network-api/src/api_impl.rs:108:47 | 108 | interface.set_bond_slave_list(&slaves)?; | ^^^^^^^ help: change this to: `slaves` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow = note: `#[warn(clippy::needless_borrow)]` on by default Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
This commit is contained in:
parent
cb4acf6d93
commit
aff76f9e0e
@ -70,7 +70,7 @@ pub async fn register_account(
|
||||
|
||||
let account = AccountData::from_account_dir_tos(account, directory_url, tos_url);
|
||||
|
||||
super::account_config::create_account_config(&name, &account)?;
|
||||
super::account_config::create_account_config(name, &account)?;
|
||||
|
||||
Ok(account.location)
|
||||
}
|
||||
@ -89,7 +89,7 @@ pub async fn deactivate_account(
|
||||
{
|
||||
Ok(account) => {
|
||||
account_data.account = account.data.clone();
|
||||
super::account_config::save_account_config(&name, &account_data)?;
|
||||
super::account_config::save_account_config(name, &account_data)?;
|
||||
}
|
||||
Err(err) if !force => return Err(err),
|
||||
Err(err) => {
|
||||
@ -102,7 +102,7 @@ pub async fn deactivate_account(
|
||||
}
|
||||
}
|
||||
|
||||
super::account_config::mark_account_deactivated(&name)?;
|
||||
super::account_config::mark_account_deactivated(name)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@ -120,7 +120,7 @@ pub async fn update_account(name: &AcmeAccountName, contact: Option<String>) ->
|
||||
|
||||
let account = client.update_account(&data).await?;
|
||||
account_data.account = account.data.clone();
|
||||
super::account_config::save_account_config(&name, &account_data)?;
|
||||
super::account_config::save_account_config(name, &account_data)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ struct PamGuard<'a> {
|
||||
|
||||
impl Drop for PamGuard<'_> {
|
||||
fn drop(&mut self) {
|
||||
pam_sys::wrapped::end(&mut self.handle, self.result);
|
||||
pam_sys::wrapped::end(self.handle, self.result);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ where
|
||||
|
||||
let is_valid = keyring.verify(
|
||||
MessageDigest::sha256(),
|
||||
&signature,
|
||||
signature,
|
||||
&self.verification_data(aad),
|
||||
)?;
|
||||
|
||||
|
@ -52,7 +52,7 @@ impl TlsOptions {
|
||||
.filter(|&b| b != b':')
|
||||
.collect();
|
||||
|
||||
let fp = <[u8; 32]>::from_hex(&hex).map_err(|_| ParseFingerprintError)?;
|
||||
let fp = <[u8; 32]>::from_hex(hex).map_err(|_| ParseFingerprintError)?;
|
||||
|
||||
Ok(Self::Fingerprint(fp.into()))
|
||||
}
|
||||
@ -469,7 +469,7 @@ fn verify_fingerprint(chain: &x509::X509StoreContextRef, expected_fingerprint: &
|
||||
|
||||
if expected_fingerprint != fp.as_ref() {
|
||||
log::error!("bad fingerprint: {}", fp_string(&fp));
|
||||
log::error!("expected fingerprint: {}", fp_string(&expected_fingerprint));
|
||||
log::error!("expected fingerprint: {}", fp_string(expected_fingerprint));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,7 @@ pub fn create_interface(iface: String, config: InterfaceUpdater) -> Result<(), E
|
||||
}
|
||||
}
|
||||
if let Some(slaves) = &config.slaves {
|
||||
interface.set_bond_slave_list(&slaves)?;
|
||||
interface.set_bond_slave_list(slaves)?;
|
||||
}
|
||||
}
|
||||
NetworkInterfaceType::Vlan => {
|
||||
|
@ -49,7 +49,7 @@ impl Recovery {
|
||||
getrandom(&mut secret)?;
|
||||
|
||||
let mut this = Self {
|
||||
secret: hex::encode(&secret),
|
||||
secret: hex::encode(secret),
|
||||
entries: Vec::with_capacity(10),
|
||||
created: proxmox_time::epoch_i64(),
|
||||
};
|
||||
@ -83,7 +83,7 @@ impl Recovery {
|
||||
.sign_oneshot_to_vec(data)
|
||||
.map_err(|err| format_err!("error calculating hmac: {}", err))?;
|
||||
|
||||
Ok(hex::encode(&hmac))
|
||||
Ok(hex::encode(hmac))
|
||||
}
|
||||
|
||||
/// Iterator over available keys.
|
||||
|
@ -36,9 +36,9 @@ impl StdError for Error {
|
||||
impl fmt::Display for Error {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
Error::Generic(e) => f.write_str(&e),
|
||||
Error::Decode(m, _e) => f.write_str(&m),
|
||||
Error::Ssl(m, _e) => f.write_str(&m),
|
||||
Error::Generic(e) => f.write_str(e),
|
||||
Error::Decode(m, _e) => f.write_str(m),
|
||||
Error::Ssl(m, _e) => f.write_str(m),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -604,14 +604,13 @@ mod bytes_as_base64 {
|
||||
use serde::{Deserialize, Deserializer, Serializer};
|
||||
|
||||
pub fn serialize<S: Serializer>(data: &[u8], serializer: S) -> Result<S::Ok, S::Error> {
|
||||
serializer.serialize_str(&base64::encode(&data))
|
||||
serializer.serialize_str(&base64::encode(data))
|
||||
}
|
||||
|
||||
pub fn deserialize<'de, D: Deserializer<'de>>(deserializer: D) -> Result<Vec<u8>, D::Error> {
|
||||
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())))
|
||||
}
|
||||
}
|
||||
|
||||
@ -625,7 +624,7 @@ mod bytes_as_base64url_nopad {
|
||||
pub fn deserialize<'de, D: Deserializer<'de>>(deserializer: D) -> Result<Vec<u8>, D::Error> {
|
||||
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()))
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user