pub struct PhoneNumberSet { /* private fields */ }Expand description
A collection of phone numbers that can be compared and deduplicated
This struct provides efficient deduplication and comparison of phone numbers.
§Examples
use phonelib::PhoneNumberSet;
let mut set = PhoneNumberSet::new();
set.add("+1-202-555-0173");
set.add("(202) 555-0173");
assert_eq!(set.len(), 1); // Same number, different formatsImplementations§
Source§impl PhoneNumberSet
impl PhoneNumberSet
Sourcepub fn add(&mut self, phone_number: &str) -> bool
pub fn add(&mut self, phone_number: &str) -> bool
Add a phone number to the set
§Returns
true- If the number was added (not a duplicate)false- If the number was already in the set
Sourcepub fn iter(&self) -> impl Iterator<Item = &PhoneNumber>
pub fn iter(&self) -> impl Iterator<Item = &PhoneNumber>
Get all unique phone numbers
Sourcepub fn normalized_numbers(&self) -> Vec<&str>
pub fn normalized_numbers(&self) -> Vec<&str>
Get all normalized phone numbers
Sourcepub fn find_duplicates(&self, phone_number: &str) -> Option<&PhoneNumber>
pub fn find_duplicates(&self, phone_number: &str) -> Option<&PhoneNumber>
Find all duplicates of a phone number (different formats)
Trait Implementations§
Source§impl Clone for PhoneNumberSet
impl Clone for PhoneNumberSet
Source§fn clone(&self) -> PhoneNumberSet
fn clone(&self) -> PhoneNumberSet
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PhoneNumberSet
impl Debug for PhoneNumberSet
Source§impl Default for PhoneNumberSet
impl Default for PhoneNumberSet
Source§fn default() -> PhoneNumberSet
fn default() -> PhoneNumberSet
Returns the “default value” for a type. Read more
Source§impl<'a> FromIterator<&'a str> for PhoneNumberSet
impl<'a> FromIterator<&'a str> for PhoneNumberSet
Source§impl FromIterator<String> for PhoneNumberSet
impl FromIterator<String> for PhoneNumberSet
Auto Trait Implementations§
impl Freeze for PhoneNumberSet
impl RefUnwindSafe for PhoneNumberSet
impl Send for PhoneNumberSet
impl Sync for PhoneNumberSet
impl Unpin for PhoneNumberSet
impl UnwindSafe for PhoneNumberSet
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more