From 18564ac463b8e90dc300e7393881eac8eb7113cc Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Wed, 1 Jan 2025 17:13:11 +0100 Subject: [PATCH] email: Reduce monomorphization overhead for the `Emails::build_message()` fn --- src/email.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/email.rs b/src/email.rs index b62cbce014b..09c16e4d95a 100644 --- a/src/email.rs +++ b/src/email.rs @@ -84,7 +84,12 @@ impl Emails { } } - fn build_message(&self, recipient: &str, email: E) -> Result { + fn build_message( + &self, + recipient: &str, + subject: String, + body: String, + ) -> Result { // The message ID is normally generated by the SMTP server, but if we let it generate the // ID there will be no way for the crates.io application to know the ID of the message it // just sent, as it's not included in the SMTP response. @@ -100,9 +105,6 @@ impl Emails { let from = Mailbox::new(Some(self.domain.clone()), self.from.clone()); - let subject = email.subject(); - let body = email.body(); - let message = Message::builder() .message_id(Some(message_id.clone())) .to(recipient.parse()?) @@ -115,7 +117,7 @@ impl Emails { } pub async fn send(&self, recipient: &str, email: E) -> Result<(), EmailError> { - let email = self.build_message(recipient, email)?; + let email = self.build_message(recipient, email.subject(), email.body())?; self.backend .send(email)