From b894d47c9a255037c63234ce9cf369372429a576 Mon Sep 17 00:00:00 2001 From: Linken Quy Dinh Date: Sat, 7 Oct 2023 16:12:49 -0300 Subject: [PATCH] use row named email --- Cargo.toml | 2 +- .../cli/commands/email_check/common.rs | 34 +++++++------------ 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f508834..5b11e76 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = 'email-validate' -version = '0.1.10' +version = '0.1.11' edition = '2021' keywords = ['email', 'validation', 'validate', 'bounce', 'free'] categories = ['email', 'validation'] diff --git a/src/features/cli/commands/email_check/common.rs b/src/features/cli/commands/email_check/common.rs index 1182b2d..eb11a5c 100644 --- a/src/features/cli/commands/email_check/common.rs +++ b/src/features/cli/commands/email_check/common.rs @@ -355,13 +355,11 @@ impl Api { let mut buf_writer = Self::get_file_writer(&path_write).await?; - for (index, x) in items.into_iter().enumerate() { - let d = if index == 0 { - x.address_email.to_string() - } else { - format!(";{}", x.address_email) - }; - Self::write_bytes_to_file(&mut buf_writer, d.as_bytes()).await?; + Self::write_bytes_to_file(&mut buf_writer, "email\n".as_bytes()).await?; + + for x in items.into_iter() { + Self::write_bytes_to_file(&mut buf_writer, format!("{}\n", x.address_email).as_bytes()) + .await?; } buf_writer.flush().await?; @@ -458,14 +456,11 @@ impl Api { .sort_by(|a, b| b.address_email.cmp(&a.address_email)); let mut buf_writer = Self::get_file_writer(&path_write).await?; + Self::write_bytes_to_file(&mut buf_writer, "email\n".as_bytes()).await?; - for (index, x) in state_c.timeouts.into_iter().enumerate() { - let d = if index == 0 { - x.address_email.to_string() - } else { - format!(";{}", x.address_email) - }; - Self::write_bytes_to_file(&mut buf_writer, d.as_bytes()).await?; + for x in state_c.timeouts.into_iter() { + Self::write_bytes_to_file(&mut buf_writer, format!("{}\n", x.address_email).as_bytes()) + .await?; } buf_writer.flush().await?; @@ -780,14 +775,11 @@ impl Api { }); let mut buf_writer = Self::get_file_writer(&path_write_all_valids).await?; + Self::write_bytes_to_file(&mut buf_writer, "email\n".as_bytes()).await?; - for (index, x) in items.into_iter().enumerate() { - let d = if index == 0 { - x.address_email.to_string() - } else { - format!(";{}", x.address_email) - }; - Self::write_bytes_to_file(&mut buf_writer, d.as_bytes()).await?; + for x in items.into_iter() { + Self::write_bytes_to_file(&mut buf_writer, format!("{}\n", x.address_email).as_bytes()) + .await?; } buf_writer.flush().await?;