Remove unused, refactor exports
This commit is contained in:
18
src/lib.rs
18
src/lib.rs
@@ -13,4 +13,20 @@ pub(crate) mod string_util;
|
||||
/// boilerplate places in the code that can be replaced with macros,
|
||||
/// the name of which will describe what is happening more
|
||||
/// clearly than a few lines of code.
|
||||
mod macros;
|
||||
mod macros;
|
||||
|
||||
pub use phonenumberutil::{
|
||||
PHONE_NUMBER_UTIL,
|
||||
phonenumberutil::{
|
||||
RegexResult,
|
||||
MatchResult,
|
||||
ParseResult,
|
||||
ValidationResult,
|
||||
ExampleNumberResult,
|
||||
InternalLogicResult,
|
||||
ExtractNumberResult,
|
||||
PhoneNumberUtil
|
||||
},
|
||||
errors,
|
||||
enums
|
||||
};
|
||||
@@ -1,5 +1,4 @@
|
||||
use strum::EnumIter;
|
||||
use thiserror::Error;
|
||||
|
||||
/// INTERNATIONAL and NATIONAL formats are consistent with the definition
|
||||
/// in ITU-T Recommendation E.123. However we follow local conventions such as
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use core::error;
|
||||
use std::num::ParseIntError;
|
||||
|
||||
use thiserror::Error;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
mod helper_constants;
|
||||
pub mod helper_functions;
|
||||
mod errors;
|
||||
mod enums;
|
||||
mod phonenumberutil;
|
||||
mod helper_functions;
|
||||
pub mod errors;
|
||||
pub mod enums;
|
||||
pub mod phonenumberutil;
|
||||
mod phone_number_regexps_and_mappings;
|
||||
pub(self) mod helper_types;
|
||||
pub(self) mod comparisons;
|
||||
@@ -10,10 +10,8 @@ pub(self) mod comparisons;
|
||||
use std::sync::LazyLock;
|
||||
|
||||
pub use enums::{MatchType, PhoneNumberFormat, PhoneNumberType, ValidNumberLenType};
|
||||
use thiserror::Error;
|
||||
use crate::phonenumberutil::phonenumberutil::PhoneNumberUtil;
|
||||
|
||||
// use crate::phonenumberutil::phonenumberutil::PhoneNumberUtil;
|
||||
|
||||
// static PHONE_NUMBER_UTIL: LazyLock<PhoneNumberUtil> = LazyLock::new(|| {
|
||||
// PhoneNumberUtil::new()
|
||||
// });
|
||||
pub static PHONE_NUMBER_UTIL: LazyLock<PhoneNumberUtil> = LazyLock::new(|| {
|
||||
PhoneNumberUtil::new()
|
||||
});
|
||||
@@ -1,5 +1,5 @@
|
||||
use std::{
|
||||
borrow::Cow, cmp::max, collections::{hash_map, HashMap, HashSet, VecDeque}, sync::Arc
|
||||
borrow::Cow, cmp::max, collections::{HashMap, HashSet, VecDeque}, sync::Arc
|
||||
};
|
||||
|
||||
use super::phone_number_regexps_and_mappings::PhoneNumberRegExpsAndMappings;
|
||||
@@ -136,13 +136,13 @@ impl PhoneNumberUtil {
|
||||
self.country_code_to_non_geographical_metadata_map.keys().map(| k | *k)
|
||||
}
|
||||
|
||||
fn get_supported_calling_codes(&self) -> impl Iterator<Item=i32> {
|
||||
pub fn get_supported_calling_codes(&self) -> impl Iterator<Item=i32> {
|
||||
self.country_calling_code_to_region_code_map
|
||||
.iter()
|
||||
.map(| (k, _) | *k)
|
||||
}
|
||||
|
||||
fn get_supported_types_for_region(
|
||||
pub fn get_supported_types_for_region(
|
||||
&self,
|
||||
region_code: &str,
|
||||
) -> Option<HashSet<PhoneNumberType>> {
|
||||
@@ -155,7 +155,7 @@ impl PhoneNumberUtil {
|
||||
})
|
||||
}
|
||||
|
||||
fn get_supported_types_for_non_geo_entity(
|
||||
pub fn get_supported_types_for_non_geo_entity(
|
||||
&self,
|
||||
country_calling_code: i32,
|
||||
) -> Option<HashSet<PhoneNumberType>> {
|
||||
|
||||
@@ -14,11 +14,6 @@ pub trait RegexConsume {
|
||||
fn find_start<'a>(&self, s: &'a str) -> Option<Match<'a>>;
|
||||
}
|
||||
|
||||
trait RegexMatchStart {
|
||||
// Eq of looking_at
|
||||
fn match_start(&self, s: &str) -> bool;
|
||||
}
|
||||
|
||||
impl RegexFullMatch for Regex {
|
||||
fn full_match(&self, s: &str) -> bool {
|
||||
let found = self.find(s);
|
||||
@@ -29,16 +24,6 @@ impl RegexFullMatch for Regex {
|
||||
}
|
||||
}
|
||||
|
||||
impl RegexMatchStart for Regex {
|
||||
fn match_start(&self, s: &str) -> bool {
|
||||
let found = self.find(s);
|
||||
if let Some(matched) = found {
|
||||
return matched.start() == 0;
|
||||
}
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
impl RegexConsume for Regex {
|
||||
fn captures_start<'a>(&self, s: &'a str) -> Option<Captures<'a>> {
|
||||
let captures = self.captures(s)?;
|
||||
|
||||
@@ -12,12 +12,7 @@ pub struct RegexCache {
|
||||
}
|
||||
|
||||
impl RegexCache {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
cache: DashMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub fn with_capacity(capacity: usize) -> Self {
|
||||
Self {
|
||||
cache: DashMap::with_capacity(capacity),
|
||||
|
||||
Reference in New Issue
Block a user