Clippy fixes

This commit is contained in:
Maurus Decimus
2026-07-09 15:26:03 +02:00
parent e2d0505013
commit e21fc8bc9d
9 changed files with 15 additions and 19 deletions

View File

@@ -28,7 +28,7 @@ pub(crate) fn sign(
};
let protected = Protected::encode("ES256", jwk, kid, nonce.into(), url)?;
let payload = URL_SAFE_NO_PAD.encode(payload);
let combined = format!("{}.{}", &protected, &payload);
let combined = format!("{}.{}", protected, payload);
let signature = key
.sign(&SystemRandom::new(), combined.as_bytes())
.map_err(|err| AcmeError::Crypto(format!("Failed to sign payload: {}", err)))?;
@@ -49,7 +49,7 @@ pub(crate) fn eab_sign(
) -> AcmeResult<Body> {
let protected = Protected::encode("HS256", None, kid.into(), None, url)?;
let payload = Jwk::new(key).base64()?;
let combined = format!("{}.{}", &protected, &payload);
let combined = format!("{}.{}", protected, payload);
let key = hmac::Key::new(hmac::HMAC_SHA256, hmac_key);
let tag = hmac::sign(&key, combined.as_bytes());

View File

@@ -68,7 +68,7 @@ pub fn fn_cosine_similarity<'x>(_: &'x Context<'x>, v: Vec<Variable>) -> Variabl
let mut magnitude_a = 0;
let mut magnitude_b = 0;
for (_word, count) in word_freq.iter() {
for count in word_freq.values() {
dot_product += count[0] * count[1];
magnitude_a += count[0] * count[0];
magnitude_b += count[1] * count[1];
@@ -95,7 +95,7 @@ pub fn cosine_similarity(a: &[&str], b: &[&str]) -> f64 {
let mut magnitude_a = 0;
let mut magnitude_b = 0;
for (_word, count) in word_freq.iter() {
for count in word_freq.values() {
dot_product += count[0] * count[1];
magnitude_a += count[0] * count[0];
magnitude_b += count[1] * count[1];

View File

@@ -208,11 +208,7 @@ pub fn quoted_string(buf: &mut Vec<u8>, text: &str) {
}
pub fn quoted_or_literal_string(buf: &mut Vec<u8>, text: &str) {
if text
.as_bytes()
.iter()
.any(|ch| [b'\\', b'"', b'\r', b'\n'].contains(ch))
{
if text.as_bytes().iter().any(|ch| b"\\\"\r\n".contains(ch)) {
literal_string(buf, text.as_bytes())
} else {
buf.push(b'"');

View File

@@ -408,7 +408,7 @@ impl VacationResponseSet for Server {
script.push(b'\"');
for ch in message_body {
if [b'\\', b'\"'].contains(&ch) {
if b"\\\"".contains(&ch) {
script.push(b'\\');
}
script.push(ch);

View File

@@ -208,7 +208,7 @@ impl StatusResponse {
if !self.message.is_empty() {
buf.extend_from_slice(b" \"");
for ch in self.message.as_bytes() {
if [b'\"', b'\\'].contains(ch) {
if b"\"\\".contains(ch) {
buf.push(b'\\');
}
buf.push(*ch);
@@ -290,7 +290,7 @@ impl SerializeResponse for trc::Error {
.unwrap_or_else(|| self.as_ref().message());
buf.extend_from_slice(b" \"");
for ch in message.as_bytes() {
if [b'\"', b'\\'].contains(ch) {
if b"\"\\".contains(ch) {
buf.push(b'\\');
}
buf.push(*ch);

View File

@@ -54,7 +54,7 @@ impl<T: SessionStream> Session<T> {
.caused_by(trc::location!())?;
response.push(b'\"');
for ch in script.name.as_bytes() {
if [b'\\', b'\"'].contains(ch) {
if b"\\\"".contains(ch) {
response.push(b'\\');
}
response.push(*ch);