Trait chinese_number::ChineseToNumber
source · pub trait ChineseToNumber<T> {
// Required methods
fn to_number(
&self,
method: ChineseCountMethod
) -> Result<T, ChineseToNumberError>;
fn to_number_naive(&self) -> Result<T, ChineseToNumberError>;
}
Available on crate feature
chinese-to-number
only.Expand description
讓 Rust 程式語言的字串型別擁有將中文數字轉成數值的能力。
Required Methods§
sourcefn to_number(
&self,
method: ChineseCountMethod
) -> Result<T, ChineseToNumberError>
fn to_number( &self, method: ChineseCountMethod ) -> Result<T, ChineseToNumberError>
將中文數字轉成數值。
範例
use chinese_number::{ChineseCountMethod, ChineseToNumber};
assert_eq!(1234567890123456789u64, "一百二十三京四千五百六十七兆八千九百零一億二千三百四十五萬六千七百八十九".to_number(ChineseCountMethod::TenThousand).unwrap());
sourcefn to_number_naive(&self) -> Result<T, ChineseToNumberError>
fn to_number_naive(&self) -> Result<T, ChineseToNumberError>
將中文數字直接轉成數值,不進行單位計算。
範例
use chinese_number::{ChineseCountMethod, ChineseToNumber};
assert_eq!(123456789u64, "一二三四五六七八九".to_number_naive().unwrap());