use char when replacing a single character

Reasons:
- More idiomatic use of string.

Considering that they are constants, I don't anticipate any performance
gains related to heap-allocation.

Signed-off-by: Perma Alesheikh <me@prma.dev>
This commit is contained in:
Perma Alesheikh 2024-01-09 12:47:19 +03:30 committed by Clément DOUIN
parent f7a7937cb1
commit 0ff940871b
No known key found for this signature in database
GPG key ID: 353E4A18EE0FAB72
5 changed files with 5 additions and 5 deletions

View file

@ -12,7 +12,7 @@ pub struct MessageRawBodyArg {
impl MessageRawBodyArg {
pub fn raw(self) -> String {
self.raw.join(" ").replace("\r", "").replace("\n", "\r\n")
self.raw.join(" ").replace('\r', "").replace('\n', "\r\n")
}
}

View file

@ -12,7 +12,7 @@ pub struct HeaderRawArgs {
}
pub fn raw_header_parser(raw_header: &str) -> Result<(String, String), String> {
if let Some((key, val)) = raw_header.split_once(":") {
if let Some((key, val)) = raw_header.split_once(':') {
Ok((key.trim().to_owned(), val.trim().to_owned()))
} else {
Err(format!("cannot parse raw header {raw_header:?}"))

View file

@ -15,6 +15,6 @@ pub struct MessageRawArg {
impl MessageRawArg {
pub fn raw(self) -> String {
self.raw.join(" ").replace("\r", "").replace("\n", "\r\n")
self.raw.join(" ").replace('\r', "").replace('\n', "\r\n")
}
}

View file

@ -12,7 +12,7 @@ pub struct TemplateRawBodyArg {
impl TemplateRawBodyArg {
pub fn raw(self) -> String {
self.raw.join(" ").replace("\r", "")
self.raw.join(" ").replace('\r', "")
}
}

View file

@ -13,6 +13,6 @@ pub struct TemplateRawArg {
impl TemplateRawArg {
pub fn raw(self) -> String {
self.raw.join(" ").replace("\r", "")
self.raw.join(" ").replace('\r', "")
}
}