pub fn normalize<'a>(mut number: Number<'a>, mappings: &FnvHashMap<char, char>) -> Number<'a> {
	fn act<'a>(value: Cow<'a, str>, mappings: &FnvHashMap<char, char>) -> Cow<'a, str> {
		let mut owned = None;
		{
			let mut chars = value.char_indices();

			while let Some((start, ch)) = chars.next() {
				if !ch.is_dec_digit() {
					let mut string = String::from(&value[.. start]);

					if let Some(ch) = ch.as_dec_digit() {
						string.push(ch);
					}
					else if let Some(&ch) = mappings.get(&ch) {
						string.push(ch);
					}

					while let Some((_, ch)) = chars.next() {
						if let Some(ch) = ch.as_dec_digit() {
							string.push(ch);
						}
						else if let Some(&ch) = mappings.get(&ch) {
							string.push(ch);
						}
					}

					owned = Some(string);
				}
			}
		}

		owned.map(Cow::Owned).unwrap_or(value)
	}

	number.national  = act(number.national, mappings);
	number.prefix    = number.prefix.map(|p| act(p, mappings));
	number.extension = number.extension.map(|e| act(e, mappings));

	number
}
/// Normalize a given `Number`, replacing the characters matching the mappings
/// and converting any Unicode non-decimal digits into their decimal
/// counterpart.
///
/// Note if the `Number` is already normalized it does not get modified.
Normalize a given `Number`, replacing the characters matching the mappings
and converting any Unicode non-decimal digits into their decimal
counterpart.

Note if the `Number` is already normalized it does not get modified.
Normalize a given ` Number ` replacing the characters matching the mappings and converting any Unicode non - decimal digits into their decimal counterpart . Note if the ` Number ` is already normalized it does not get modified .
pub fn normalize<'a>(mut number: Number<'a>, mappings: &FnvHashMap<char, char>) -> Number<'a> {
	fn act<'a>(value: Cow<'a, str>, mappings: &FnvHashMap<char, char>) -> Cow<'a, str> {
		let mut owned = None;
		{
			let mut chars = value.char_indices();
			while let Some((start, ch)) = chars.next() {
				if !ch.is_dec_digit() {
					let mut string = String::from(&value[.. start]);
					if let Some(ch) = ch.as_dec_digit() {
						string.push(ch);
					}
					else if let Some(&ch) = mappings.get(&ch) {
						string.push(ch);
					}
					while let Some((_, ch)) = chars.next() {
						if let Some(ch) = ch.as_dec_digit() {
							string.push(ch);
						}
						else if let Some(&ch) = mappings.get(&ch) {
							string.push(ch);
						}
					}
					owned = Some(string);
				}
			}
		}
		owned.map(Cow::Owned).unwrap_or(value)
	}
	number.national  = act(number.national, mappings);
	number.prefix    = number.prefix.map(|p| act(p, mappings));
	number.extension = number.extension.map(|e| act(e, mappings));
	number
}
pub fn normalize < ' a > ( mut number : Number < ' a > , mappings : & FnvHashMap < char , char > ) -> Number < ' a > { fn act < ' a > ( value : Cow < ' a , str > , mappings : & FnvHashMap < char , char > ) -> Cow < ' a , str > { let mut owned = None ; { let mut chars = value . char_indices ( ) ; while let Some ( ( start , ch ) ) = chars . next ( ) { if ! ch . is_dec_digit ( ) { let mut string = String :: from ( & value [ .. start ] ) ; if let Some ( ch ) = ch . as_dec_digit ( ) { string . push ( ch ) ; } else if let Some ( & ch ) = mappings . get ( & ch ) { string . push ( ch ) ; } while let Some ( ( _ , ch ) ) = chars . next ( ) { if let Some ( ch ) = ch . as_dec_digit ( ) { string . push ( ch ) ; } else if let Some ( & ch ) = mappings . get ( & ch ) { string . push ( ch ) ; } } owned = Some ( string ) ; } } } owned . map ( Cow :: Owned ) . unwrap_or ( value ) } number . national = act ( number . national , mappings ) ; number . prefix = number . prefix . map ( | p | act ( p , mappings ) ) ; number . extension = number . extension . map ( | e | act ( e , mappings ) ) ; number }
Normalize a given `Number`, replacing the characters matching the mappings
and converting any Unicode non-decimal digits into their decimal
counterpart.
Normalize a given ` Number ` replacing the characters matching the mappings and converting any Unicode non - decimal digits into their decimal counterpart .
number
Number<'a>
mappings
&FnvHashMap<char, char>