perf: use slices instead of cloning

This commit is contained in:
Sandro Eiler 2024-02-27 15:06:40 +01:00
parent e07e4dfe53
commit 506c632342

View file

@ -34,11 +34,11 @@ impl EmailClient {
// TODO: use `reqwest::Url::join` and change `base_url`'s type from `String` to `reqwest::Url`
let url = format!("{}/email", self.base_url);
let request_body = SendEmailRequest {
from: self.sender.as_ref().to_owned(),
to: recipient.as_ref().to_owned(),
subject: subject.to_owned(),
html_body: html_content.to_owned(),
text_body: text_content.to_owned(),
from: self.sender.as_ref(),
to: recipient.as_ref(),
subject,
html_body: html_content,
text_body: text_content,
};
let _builder = self
.http_client
@ -55,12 +55,12 @@ impl EmailClient {
}
#[derive(serde::Serialize)]
#[serde(rename_all = "PascalCase")]
struct SendEmailRequest {
from: String,
to: String,
subject: String,
html_body: String,
text_body: String,
struct SendEmailRequest<'a> {
from: &'a str,
to: &'a str,
subject: &'a str,
html_body: &'a str,
text_body: &'a str,
}
#[cfg(test)]