Fix clippy lints for sasl crate

This commit is contained in:
Lucas Kent 2024-05-06 08:01:54 +10:00 committed by pep
commit 1449d300dd
8 changed files with 37 additions and 46 deletions

View file

@ -86,9 +86,9 @@ impl Secret {
) -> Secret {
Secret::Password(Password::Pbkdf2 {
method: method.into(),
salt: salt,
iterations: iterations,
data: data,
salt,
iterations,
data,
})
}
}
@ -135,7 +135,7 @@ fn xor_works() {
pub fn xor(a: &[u8], b: &[u8]) -> Vec<u8> {
assert_eq!(a.len(), b.len());
let mut ret = Vec::with_capacity(a.len());
for (a, b) in a.into_iter().zip(b) {
for (a, b) in a.iter().zip(b) {
ret.push(a ^ b);
}
ret
@ -149,11 +149,8 @@ pub fn parse_frame(frame: &[u8]) -> Result<HashMap<String, String>, FromUtf8Erro
let mut tmp = s.splitn(2, '=');
let key = tmp.next();
let val = tmp.next();
match (key, val) {
(Some(k), Some(v)) => {
ret.insert(k.to_owned(), v.to_owned());
}
_ => (),
if let (Some(k), Some(v)) = (key, val) {
ret.insert(k.to_owned(), v.to_owned());
}
}
Ok(ret)

View file

@ -14,7 +14,7 @@ use base64::{engine::general_purpose::STANDARD as Base64, Engine};
pub fn generate_nonce() -> Result<String, RngError> {
let mut data = [0u8; 32];
getrandom(&mut data)?;
Ok(Base64.encode(&data))
Ok(Base64.encode(data))
}
#[derive(Debug, PartialEq)]
@ -111,7 +111,7 @@ impl ScramProvider for Sha1 {
method.to_string(),
Self::name().to_string(),
))
} else if my_salt == &salt {
} else if my_salt == salt {
Err(DeriveError::IncorrectSalt)
} else if my_iterations == iterations {
Err(DeriveError::IncompatibleIterationCount(
@ -171,7 +171,7 @@ impl ScramProvider for Sha256 {
method.to_string(),
Self::name().to_string(),
))
} else if my_salt == &salt {
} else if my_salt == salt {
Err(DeriveError::IncorrectSalt)
} else if my_iterations == iterations {
Err(DeriveError::IncompatibleIterationCount(