From 27c3c108099753744119ef46f109eae2f4def9ca Mon Sep 17 00:00:00 2001 From: phoenix Date: Sat, 6 Jun 2026 11:56:42 -0400 Subject: [PATCH] Finished remove_dupes --- src/parser/mod.rs | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/parser/mod.rs b/src/parser/mod.rs index 5a6722d..19262b1 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -18,10 +18,21 @@ impl NumberParser { let contains_letters = line.chars().any(|c| LETTERS.contains(c)); if contains_letters { continue; + } else { + let my_obj = textsender_models::contact::Contact { + phone_number: line.clone(), + ..Default::default() + }; + if !my_obj.phone_number.is_empty() { + objs.push(my_obj); + } } } - Ok(objs) + let updated_contacts = self.update_contacts(&objs); + let removed_duplicates = self.remove_dups(&updated_contacts); + + Ok(removed_duplicates) } Err(err) => { Err(err) @@ -156,21 +167,6 @@ func (prsr *NumberParser) updateContacts(contacts []contact.Contact) []contact.C } -func (prsr *NumberParser) removeDups(contacts []contact.Contact) []contact.Contact { - updated := []contact.Contact{} - uniqueItems := make(map[string]string) - - for _, val := range contacts { - uniqueItems[val.PhoneNumber] = val.PhoneNumber - } - - for _, item := range uniqueItems { - updated = append(updated, contact.Contact{PhoneNumber: item}) - } - - return updated -} - func (prsr NumberParser) SaveFile(vals []contact.Contact) { filename := "numbers.json"