From 04c83fc20d53571947b7716541cf8551254c3d57 Mon Sep 17 00:00:00 2001 From: Alexis Mousset Date: Mon, 17 Jul 2017 14:30:42 +0200 Subject: [PATCH] feat(transport): Fix benches --- lettre/benches/transport_smtp.rs | 18 +++++++++--------- lettre/src/sendmail/mod.rs | 26 ++++++++++++-------------- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/lettre/benches/transport_smtp.rs b/lettre/benches/transport_smtp.rs index e511525..33e471e 100644 --- a/lettre/benches/transport_smtp.rs +++ b/lettre/benches/transport_smtp.rs @@ -3,7 +3,7 @@ extern crate lettre; extern crate test; -use lettre::{EmailTransport, SimpleSendableEmail}; +use lettre::{EmailAddress, EmailTransport, SimpleSendableEmail}; use lettre::smtp::SmtpTransportBuilder; #[bench] @@ -11,10 +11,10 @@ fn bench_simple_send(b: &mut test::Bencher) { let mut sender = SmtpTransportBuilder::new("127.0.0.1:2525").unwrap().build(); b.iter(|| { let email = SimpleSendableEmail::new( - "user@localhost", - vec!["root@localhost"], - "id", - "Hello world", + EmailAddress::new("user@localhost".to_string()), + vec![EmailAddress::new("root@localhost".to_string())], + "id".to_string(), + "Hello world".to_string(), ); let result = sender.send(email); assert!(result.is_ok()); @@ -29,10 +29,10 @@ fn bench_reuse_send(b: &mut test::Bencher) { .build(); b.iter(|| { let email = SimpleSendableEmail::new( - "user@localhost", - vec!["root@localhost"], - "file_id", - "Hello file", + EmailAddress::new("user@localhost".to_string()), + vec![EmailAddress::new("root@localhost".to_string())], + "id".to_string(), + "Hello world".to_string(), ); let result = sender.send(email); assert!(result.is_ok()); diff --git a/lettre/src/sendmail/mod.rs b/lettre/src/sendmail/mod.rs index c3c880e..68b0612 100644 --- a/lettre/src/sendmail/mod.rs +++ b/lettre/src/sendmail/mod.rs @@ -46,20 +46,18 @@ impl EmailTransport for SendmailTransport { fn send(&mut self, email: T) -> SendmailResult { // Spawn the sendmail command let to_addresses: Vec = email.to().iter().map(|x| x.to_string()).collect(); - let mut process = - Command::new(&self.command) - .args( - &[ - "-i", - "-f", - &email.from().to_string(), - &to_addresses.join(" "), - ], - ) - .stdin(Stdio::piped()) - .stdout(Stdio::piped()) - .spawn() - ?; + let mut process = Command::new(&self.command) + .args( + &[ + "-i", + "-f", + &email.from().to_string(), + &to_addresses.join(" "), + ], + ) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .spawn()?; match process.stdin.as_mut().unwrap().write_all( email.message().as_bytes(),