pub trait NumberToChinese {
    // Required methods
    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;
}
Available on crate feature number-to-chinese only.
Expand description

讓 Rust 程式語言的所有基本數值型別擁有轉成中文數字的能力。

Required Methods§

source

fn to_chinese( self, chinese_variant: ChineseVariant, chinese_case: ChineseCase, method: ChineseCountMethod ) -> Result<String, NumberToChineseError>

將數值轉成中文數字。

  • 如果使用 「下數」,則數值的絕對值不能大於或等於 1_0000_0000_0000_0000
  • 如果使用 「萬進」,則數值的絕對值不能大於或等於 1e52
  • 如果使用 「中數」,則數值的絕對值不能大於或等於 1e96
範例
use chinese_number::{ChineseCase, ChineseCountMethod, ChineseVariant, NumberToChinese};

assert_eq!("一百二十三京四千五百六十七兆八千九百零一億二千三百四十五萬六千七百八十九", 1234567890123456789u64.to_chinese(ChineseVariant::Traditional, ChineseCase::Lower, ChineseCountMethod::TenThousand).unwrap());
source

fn to_chinese_naive( self, chinese_variant: ChineseVariant, chinese_case: ChineseCase ) -> String

將數值直接轉成中文數字,不進行單位計算。

範例
use chinese_number::{
    ChineseCase, ChineseCountMethod, ChineseVariant, NumberToChinese,
};

assert_eq!(
    "一二三四五六七八九",
    123456789
        .to_chinese_naive(ChineseVariant::Traditional, ChineseCase::Lower)
);

Implementations on Foreign Types§

source§

impl NumberToChinese for f32

source§

fn to_chinese( self, chinese_variant: ChineseVariant, chinese_case: ChineseCase, method: ChineseCountMethod ) -> Result<String, NumberToChineseError>

source§

fn to_chinese_naive( self, chinese_variant: ChineseVariant, chinese_case: ChineseCase ) -> String

source§

impl NumberToChinese for f64

source§

fn to_chinese( self, chinese_variant: ChineseVariant, chinese_case: ChineseCase, method: ChineseCountMethod ) -> Result<String, NumberToChineseError>

source§

fn to_chinese_naive( self, chinese_variant: ChineseVariant, chinese_case: ChineseCase ) -> String

source§

impl NumberToChinese for i8

source§

fn to_chinese( self, chinese_variant: ChineseVariant, chinese_case: ChineseCase, method: ChineseCountMethod ) -> Result<String, NumberToChineseError>

source§

fn to_chinese_naive( self, chinese_variant: ChineseVariant, chinese_case: ChineseCase ) -> String

source§

impl NumberToChinese for i16

source§

fn to_chinese( self, chinese_variant: ChineseVariant, chinese_case: ChineseCase, method: ChineseCountMethod ) -> Result<String, NumberToChineseError>

source§

fn to_chinese_naive( self, chinese_variant: ChineseVariant, chinese_case: ChineseCase ) -> String

source§

impl NumberToChinese for i32

source§

fn to_chinese( self, chinese_variant: ChineseVariant, chinese_case: ChineseCase, method: ChineseCountMethod ) -> Result<String, NumberToChineseError>

source§

fn to_chinese_naive( self, chinese_variant: ChineseVariant, chinese_case: ChineseCase ) -> String

source§

impl NumberToChinese for i64

source§

fn to_chinese( self, chinese_variant: ChineseVariant, chinese_case: ChineseCase, method: ChineseCountMethod ) -> Result<String, NumberToChineseError>

source§

fn to_chinese_naive( self, chinese_variant: ChineseVariant, chinese_case: ChineseCase ) -> String

source§

impl NumberToChinese for i128

source§

fn to_chinese( self, chinese_variant: ChineseVariant, chinese_case: ChineseCase, method: ChineseCountMethod ) -> Result<String, NumberToChineseError>

source§

fn to_chinese_naive( self, chinese_variant: ChineseVariant, chinese_case: ChineseCase ) -> String

source§

impl NumberToChinese for u8

source§

fn to_chinese( self, chinese_variant: ChineseVariant, chinese_case: ChineseCase, method: ChineseCountMethod ) -> Result<String, NumberToChineseError>

source§

fn to_chinese_naive( self, chinese_variant: ChineseVariant, chinese_case: ChineseCase ) -> String

source§

impl NumberToChinese for u16

source§

fn to_chinese( self, chinese_variant: ChineseVariant, chinese_case: ChineseCase, method: ChineseCountMethod ) -> Result<String, NumberToChineseError>

source§

fn to_chinese_naive( self, chinese_variant: ChineseVariant, chinese_case: ChineseCase ) -> String

source§

impl NumberToChinese for u32

source§

fn to_chinese( self, chinese_variant: ChineseVariant, chinese_case: ChineseCase, method: ChineseCountMethod ) -> Result<String, NumberToChineseError>

source§

fn to_chinese_naive( self, chinese_variant: ChineseVariant, chinese_case: ChineseCase ) -> String

source§

impl NumberToChinese for u64

source§

fn to_chinese( self, chinese_variant: ChineseVariant, chinese_case: ChineseCase, method: ChineseCountMethod ) -> Result<String, NumberToChineseError>

source§

fn to_chinese_naive( self, chinese_variant: ChineseVariant, chinese_case: ChineseCase ) -> String

source§

impl NumberToChinese for u128

source§

fn to_chinese( self, chinese_variant: ChineseVariant, chinese_case: ChineseCase, method: ChineseCountMethod ) -> Result<String, NumberToChineseError>

source§

fn to_chinese_naive( self, chinese_variant: ChineseVariant, chinese_case: ChineseCase ) -> String

Implementors§