Struct JapaneseNumber

Source
pub struct JapaneseNumber { /* private fields */ }

Implementations§

Source§

impl JapaneseNumber

Source

pub fn convert(number: usize) -> JapaneseNumber

§Example
let result = japanese_number_converter::
            JapaneseNumber::convert(100);
println!("Result : {}  =>  {}  =>  {}  =>  {}",
    result.arabiasuji(),result.kanji(),result.katakana(),result.romaji());
    // Result : 100  =>  百  =>  ヒャク   =>  hyaku  
§Panics

The lib support conversion of numbers from 0 upt to 1844_6744_0737_0955_1615. It basically convert a number which can be contained in a usize variable. When the value cannot be contained in a usize variable, it will raise an error.

§Example :
    let result = japanese_number_converter::
        JapaneseNumber::convert(1844_6744_0737_0955_1616);
    println!("Result : {}  =>  {}  =>  {}  =>  {}",
    result.arabiasuji(),result.kanji(),result.katakana(),result.romaji());
    // error: literal out of range for `usize`
    // note: the literal `1844_6744_0737_0955_1616` does not fit into the type `usize`
    //      whose range is `0..=18446744073709551615`
Source

pub fn arabiasuji(&self) -> usize

Get the arabic number

Source

pub fn kanji(&self) -> &String

Get the kanji version of the converted number

Source

pub fn romaji(&self) -> &String

Get the romaji version of the converted number

Source

pub fn katakana(&self) -> &String

Get the katakana version of the converted number

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.