From 0ead3cde09a02918e3976aa442329fe247f05c55 Mon Sep 17 00:00:00 2001 From: Alexis Mousset Date: Sat, 18 May 2019 19:33:37 +0200 Subject: [PATCH] Simplify header formatting and fix nightly build (fixes #340) --- lettre_email/src/lib.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lettre_email/src/lib.rs b/lettre_email/src/lib.rs index 4231505..c2d83e2 100644 --- a/lettre_email/src/lib.rs +++ b/lettre_email/src/lib.rs @@ -127,7 +127,7 @@ impl PartBuilder { /// Adds a `ContentType` header with the given MIME type pub fn content_type(self, content_type: &Mime) -> PartBuilder { - self.header(("Content-Type", format!("{}", content_type).as_ref())) + self.header(("Content-Type", content_type.to_string())) } /// Adds a child part @@ -299,7 +299,7 @@ impl EmailBuilder { .body(body) .header(( "Content-Type", - format!("{}", mime::TEXT_PLAIN_UTF_8).as_ref(), + mime::TEXT_PLAIN_UTF_8.to_string(), )) .build(); self.child(text) @@ -311,7 +311,7 @@ impl EmailBuilder { .body(body) .header(( "Content-Type", - format!("{}", mime::TEXT_HTML_UTF_8).as_ref(), + mime::TEXT_HTML_UTF_8.to_string(), )) .build(); self.child(html) @@ -327,7 +327,7 @@ impl EmailBuilder { .body(body_text) .header(( "Content-Type", - format!("{}", mime::TEXT_PLAIN_UTF_8).as_ref(), + mime::TEXT_PLAIN_UTF_8.to_string(), )) .build(); @@ -335,7 +335,7 @@ impl EmailBuilder { .body(body_html) .header(( "Content-Type", - format!("{}", mime::TEXT_HTML_UTF_8).as_ref(), + mime::TEXT_HTML_UTF_8.to_string(), )) .build(); @@ -375,7 +375,7 @@ impl EmailBuilder { } // Add the sender header, if any. if let Some(ref v) = self.sender { - self.message = self.message.header(("Sender", v.to_string().as_ref())); + self.message = self.message.header(("Sender", v.to_string())); } // Calculate the envelope let envelope = match self.envelope { @@ -461,7 +461,7 @@ impl EmailBuilder { if !self.date_issued { self.message = self .message - .header(("Date", Tm::rfc822z(&now()).to_string().as_ref())); + .header(("Date", Tm::rfc822z(&now()).to_string())); } self.message = self.message.header(("MIME-Version", "1.0"));