use super::*;
pub trait NumberToChinese {
fn to_chinese(
self,
chinese_variant: ChineseVariant,
chinese_case: ChineseCase,
method: ChineseCountMethod,
) -> Result<String, NumberToChineseError>;
fn to_chinese_naive(self, chinese_variant: ChineseVariant, chinese_case: ChineseCase)
-> String;
}
impl NumberToChinese for u8 {
#[inline]
fn to_chinese(
self,
chinese_variant: ChineseVariant,
chinese_case: ChineseCase,
method: ChineseCountMethod,
) -> Result<String, NumberToChineseError> {
(self as u128).to_chinese(chinese_variant, chinese_case, method)
}
#[inline]
fn to_chinese_naive(
self,
chinese_variant: ChineseVariant,
chinese_case: ChineseCase,
) -> String {
from_u8_to_chinese_naive(chinese_variant, chinese_case, self)
}
}
impl NumberToChinese for i8 {
#[inline]
fn to_chinese(
self,
chinese_variant: ChineseVariant,
chinese_case: ChineseCase,
method: ChineseCountMethod,
) -> Result<String, NumberToChineseError> {
(self as i128).to_chinese(chinese_variant, chinese_case, method)
}
#[inline]
fn to_chinese_naive(
self,
chinese_variant: ChineseVariant,
chinese_case: ChineseCase,
) -> String {
from_i8_to_chinese_naive(chinese_variant, chinese_case, self)
}
}
impl NumberToChinese for u16 {
#[inline]
fn to_chinese(
self,
chinese_variant: ChineseVariant,
chinese_case: ChineseCase,
method: ChineseCountMethod,
) -> Result<String, NumberToChineseError> {
(self as u128).to_chinese(chinese_variant, chinese_case, method)
}
#[inline]
fn to_chinese_naive(
self,
chinese_variant: ChineseVariant,
chinese_case: ChineseCase,
) -> String {
from_u16_to_chinese_naive(chinese_variant, chinese_case, self)
}
}
impl NumberToChinese for i16 {
#[inline]
fn to_chinese(
self,
chinese_variant: ChineseVariant,
chinese_case: ChineseCase,
method: ChineseCountMethod,
) -> Result<String, NumberToChineseError> {
(self as i128).to_chinese(chinese_variant, chinese_case, method)
}
#[inline]
fn to_chinese_naive(
self,
chinese_variant: ChineseVariant,
chinese_case: ChineseCase,
) -> String {
from_i16_to_chinese_naive(chinese_variant, chinese_case, self)
}
}
impl NumberToChinese for u32 {
#[inline]
fn to_chinese(
self,
chinese_variant: ChineseVariant,
chinese_case: ChineseCase,
method: ChineseCountMethod,
) -> Result<String, NumberToChineseError> {
(self as u128).to_chinese(chinese_variant, chinese_case, method)
}
#[inline]
fn to_chinese_naive(
self,
chinese_variant: ChineseVariant,
chinese_case: ChineseCase,
) -> String {
from_u32_to_chinese_naive(chinese_variant, chinese_case, self)
}
}
impl NumberToChinese for i32 {
#[inline]
fn to_chinese(
self,
chinese_variant: ChineseVariant,
chinese_case: ChineseCase,
method: ChineseCountMethod,
) -> Result<String, NumberToChineseError> {
(self as i128).to_chinese(chinese_variant, chinese_case, method)
}
#[inline]
fn to_chinese_naive(
self,
chinese_variant: ChineseVariant,
chinese_case: ChineseCase,
) -> String {
from_i32_to_chinese_naive(chinese_variant, chinese_case, self)
}
}
impl NumberToChinese for u64 {
#[inline]
fn to_chinese(
self,
chinese_variant: ChineseVariant,
chinese_case: ChineseCase,
method: ChineseCountMethod,
) -> Result<String, NumberToChineseError> {
(self as u128).to_chinese(chinese_variant, chinese_case, method)
}
#[inline]
fn to_chinese_naive(
self,
chinese_variant: ChineseVariant,
chinese_case: ChineseCase,
) -> String {
from_u64_to_chinese_naive(chinese_variant, chinese_case, self)
}
}
impl NumberToChinese for i64 {
#[inline]
fn to_chinese(
self,
chinese_variant: ChineseVariant,
chinese_case: ChineseCase,
method: ChineseCountMethod,
) -> Result<String, NumberToChineseError> {
(self as i128).to_chinese(chinese_variant, chinese_case, method)
}
#[inline]
fn to_chinese_naive(
self,
chinese_variant: ChineseVariant,
chinese_case: ChineseCase,
) -> String {
from_i64_to_chinese_naive(chinese_variant, chinese_case, self)
}
}
impl NumberToChinese for u128 {
#[inline]
fn to_chinese(
self,
chinese_variant: ChineseVariant,
chinese_case: ChineseCase,
method: ChineseCountMethod,
) -> Result<String, NumberToChineseError> {
match method {
ChineseCountMethod::Low => {
from_u128_to_chinese_low(chinese_variant, chinese_case, self)
},
ChineseCountMethod::TenThousand => {
Ok(from_u128_to_chinese_ten_thousand(chinese_variant, chinese_case, self))
},
ChineseCountMethod::Middle => {
Ok(from_u128_to_chinese_middle(chinese_variant, chinese_case, self))
},
ChineseCountMethod::High => {
Ok(from_u128_to_chinese_high(chinese_variant, chinese_case, self))
},
}
}
#[inline]
fn to_chinese_naive(
self,
chinese_variant: ChineseVariant,
chinese_case: ChineseCase,
) -> String {
from_u128_to_chinese_naive(chinese_variant, chinese_case, self)
}
}
impl NumberToChinese for i128 {
#[inline]
fn to_chinese(
self,
chinese_variant: ChineseVariant,
chinese_case: ChineseCase,
method: ChineseCountMethod,
) -> Result<String, NumberToChineseError> {
match method {
ChineseCountMethod::Low => {
from_i128_to_chinese_low(chinese_variant, chinese_case, self)
},
ChineseCountMethod::TenThousand => {
Ok(from_i128_to_chinese_ten_thousand(chinese_variant, chinese_case, self))
},
ChineseCountMethod::Middle => {
Ok(from_i128_to_chinese_middle(chinese_variant, chinese_case, self))
},
ChineseCountMethod::High => {
Ok(from_i128_to_chinese_high(chinese_variant, chinese_case, self))
},
}
}
#[inline]
fn to_chinese_naive(
self,
chinese_variant: ChineseVariant,
chinese_case: ChineseCase,
) -> String {
from_i128_to_chinese_naive(chinese_variant, chinese_case, self)
}
}
impl NumberToChinese for f32 {
#[inline]
fn to_chinese(
self,
chinese_variant: ChineseVariant,
chinese_case: ChineseCase,
method: ChineseCountMethod,
) -> Result<String, NumberToChineseError> {
(self as f64).to_chinese(chinese_variant, chinese_case, method)
}
#[inline]
fn to_chinese_naive(
self,
chinese_variant: ChineseVariant,
chinese_case: ChineseCase,
) -> String {
from_f32_to_chinese_naive(chinese_variant, chinese_case, self)
}
}
impl NumberToChinese for f64 {
#[inline]
fn to_chinese(
self,
chinese_variant: ChineseVariant,
chinese_case: ChineseCase,
method: ChineseCountMethod,
) -> Result<String, NumberToChineseError> {
match method {
ChineseCountMethod::Low => from_f64_to_chinese_low(chinese_variant, chinese_case, self),
ChineseCountMethod::TenThousand => {
from_f64_to_chinese_ten_thousand(chinese_variant, chinese_case, self)
},
ChineseCountMethod::Middle => {
from_f64_to_chinese_middle(chinese_variant, chinese_case, self)
},
ChineseCountMethod::High => {
Ok(from_f64_to_chinese_high(chinese_variant, chinese_case, self))
},
}
}
#[inline]
fn to_chinese_naive(
self,
chinese_variant: ChineseVariant,
chinese_case: ChineseCase,
) -> String {
from_f64_to_chinese_naive(chinese_variant, chinese_case, self)
}
}