Sanitaze code

This commit is contained in:
Vlasislav Kashin
2025-07-13 16:24:00 +03:00
parent f646fe4605
commit 77fa0e2b09
6 changed files with 267 additions and 249 deletions

View File

@@ -13,19 +13,3 @@ impl<'a> PhoneNumberWithCountryCodeSource<'a> {
Self { phone_number, country_code_source } Self { phone_number, country_code_source }
} }
} }
#[derive(Debug)]
pub struct PhoneNumberAndCarrierCode<'a> {
pub carrier_code: Option<&'a str>,
pub phone_number: Cow<'a, str>
}
impl<'a> PhoneNumberAndCarrierCode<'a> {
pub fn new<B: Into<Cow<'a, str>>>(carrier_code: Option<&'a str>, phone_number: B) -> Self {
Self { carrier_code, phone_number: phone_number.into() }
}
pub fn new_phone<B: Into<Cow<'a, str>>>(phone_number: B) -> Self {
Self { carrier_code: None, phone_number: phone_number.into() }
}
}

View File

@@ -8,6 +8,7 @@ use crate::{phonenumberutil::{helper_constants::{
VALID_PUNCTUATION VALID_PUNCTUATION
}, helper_functions::create_extn_pattern}, regexp_cache::RegexCache}; }, helper_functions::create_extn_pattern}, regexp_cache::RegexCache};
#[allow(unused)]
pub(super) struct PhoneNumberRegExpsAndMappings { pub(super) struct PhoneNumberRegExpsAndMappings {
/// Regular expression of viable phone numbers. This is location independent. /// Regular expression of viable phone numbers. This is location independent.
/// Checks we have at least three leading digits, and only valid punctuation, /// Checks we have at least three leading digits, and only valid punctuation,

View File

@@ -15,7 +15,6 @@
use std::{ use std::{
borrow::Cow, borrow::Cow,
cmp::max,
collections::{HashMap, HashSet, VecDeque}, collections::{HashMap, HashSet, VecDeque},
sync::Arc, sync::Arc,
}; };
@@ -36,7 +35,7 @@ use crate::{
is_national_number_suffix_of_the_other, load_compiled_metadata, normalize_helper, is_national_number_suffix_of_the_other, load_compiled_metadata, normalize_helper,
prefix_number_with_country_calling_code, test_number_length, prefix_number_with_country_calling_code, test_number_length,
test_number_length_with_unknown_type, test_number_length_with_unknown_type,
}, helper_types::{PhoneNumberAndCarrierCode, PhoneNumberWithCountryCodeSource}, MatchType, PhoneNumberFormat, PhoneNumberType, ValidNumberLenType }, helper_types::{PhoneNumberWithCountryCodeSource}, MatchType, PhoneNumberFormat, PhoneNumberType, ValidNumberLenType
}, },
phonemetadata::{NumberFormat, PhoneMetadata, PhoneNumberDesc}, phonemetadata::{NumberFormat, PhoneMetadata, PhoneNumberDesc},
phonenumber::{phone_number::CountryCodeSource, PhoneNumber}, phonenumber::{phone_number::CountryCodeSource, PhoneNumber},

View File

@@ -1,2 +1,3 @@
mod tests; #[cfg(test)]
mod phonenumberutil_tests;
pub(self) mod region_code; pub(self) mod region_code;

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,6 @@
pub struct RegionCode {} pub struct RegionCode {}
#[allow(unused)]
impl RegionCode { impl RegionCode {
pub fn ad() -> &'static str { pub fn ad() -> &'static str {
"AD" "AD"