proxmox/src/tools/email.rs: use slice instead of Vec

This commit is contained in:
Dietmar Maurer 2020-09-21 10:03:48 +02:00
parent 2702a2a7b5
commit 48d049d4bf

View File

@ -9,7 +9,7 @@ use std::process::{Command, Stdio};
/// ///
/// ``sendmail`` is used for sending the mail. /// ``sendmail`` is used for sending the mail.
pub fn sendmail( pub fn sendmail(
mailto: Vec<&str>, mailto: &[&str],
subject: &str, subject: &str,
text: Option<&str>, text: Option<&str>,
html: Option<&str>, html: Option<&str>,
@ -22,7 +22,7 @@ pub fn sendmail(
bail!("At least one recipient has to be specified!") bail!("At least one recipient has to be specified!")
} }
for recipient in &mailto { for recipient in mailto {
if !mail_regex.is_match(recipient) { if !mail_regex.is_match(recipient) {
bail!("'{}' is not a valid email address", recipient) bail!("'{}' is not a valid email address", recipient)
} }
@ -128,7 +128,7 @@ mod test {
#[test] #[test]
fn test1() { fn test1() {
let result = sendmail( let result = sendmail(
vec!["somenotvalidemail!", "somealmostvalid email"], &["somenotvalidemail!", "somealmostvalid email"],
"Subject1", "Subject1",
Some("TEXT"), Some("TEXT"),
Some("<b>HTML</b>"), Some("<b>HTML</b>"),
@ -141,7 +141,7 @@ mod test {
#[test] #[test]
fn test2() { fn test2() {
let result = sendmail( let result = sendmail(
vec![], &[],
"Subject2", "Subject2",
None, None,
Some("<b>HTML</b>"), Some("<b>HTML</b>"),
@ -154,7 +154,7 @@ mod test {
#[test] #[test]
fn test3() { fn test3() {
let result = sendmail( let result = sendmail(
vec!["a@b.c"], &["a@b.c"],
"Subject3", "Subject3",
None, None,
Some("<b>HTML</b>"), Some("<b>HTML</b>"),