From eceb61f9b63975798a54c0edd71509d225b3cf17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodolphe=20Br=C3=A9ard?= Date: Sat, 7 May 2022 12:19:24 +0200 Subject: [PATCH] Use a char instead of a string in `.replace()` --- acme_common/src/crypto.rs | 2 +- acme_common/src/crypto/key_type.rs | 2 +- acme_common/src/crypto/openssl_keys.rs | 4 ++-- acmed/src/config.rs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/acme_common/src/crypto.rs b/acme_common/src/crypto.rs index cf59282..e8fc314 100644 --- a/acme_common/src/crypto.rs +++ b/acme_common/src/crypto.rs @@ -58,7 +58,7 @@ impl FromStr for BaseHashFunction { type Err = Error; fn from_str(s: &str) -> Result { - let s = s.to_lowercase().replace("-", "").replace("_", ""); + let s = s.to_lowercase().replace('-', "").replace('_', ""); match s.as_str() { "sha256" => Ok(BaseHashFunction::Sha256), "sha384" => Ok(BaseHashFunction::Sha384), diff --git a/acme_common/src/crypto/key_type.rs b/acme_common/src/crypto/key_type.rs index eb08822..36ae6d8 100644 --- a/acme_common/src/crypto/key_type.rs +++ b/acme_common/src/crypto/key_type.rs @@ -71,7 +71,7 @@ impl FromStr for KeyType { type Err = Error; fn from_str(s: &str) -> Result { - match s.to_lowercase().replace("-", "_").as_str() { + match s.to_lowercase().replace('-', "_").as_str() { "rsa2048" => Ok(KeyType::Rsa2048), "rsa4096" => Ok(KeyType::Rsa4096), "ecdsa_p256" => Ok(KeyType::EcdsaP256), diff --git a/acme_common/src/crypto/openssl_keys.rs b/acme_common/src/crypto/openssl_keys.rs index 8f4a142..8f90928 100644 --- a/acme_common/src/crypto/openssl_keys.rs +++ b/acme_common/src/crypto/openssl_keys.rs @@ -269,8 +269,8 @@ impl KeyPair { x += &pem_line .trim() .trim_end_matches('=') - .replace("/", "_") - .replace("+", "-"); + .replace('/', "_") + .replace('+', "-"); } } x.replace_range(..16, ""); diff --git a/acmed/src/config.rs b/acmed/src/config.rs index 2589330..cad774f 100644 --- a/acmed/src/config.rs +++ b/acmed/src/config.rs @@ -483,7 +483,7 @@ impl Certificate { id.to_string() } }; - let name = name.replace("*", "_").replace(":", "_").replace("/", "_"); + let name = name.replace('*', "_").replace(':', "_").replace('/', "_"); Ok(name) }