kansuji 0.1.1

漢数字と数字の相互変換のためのライブラリ
Documentation
  • Coverage
  • 14.29%
    1 out of 7 items documented1 out of 3 items with examples
  • Size
  • Source code size: 39.53 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.56 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 14s Average build duration of successful builds.
  • all releases: 14s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • puripuri2100/kansuji-rs
    5 0 1
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • puripuri2100

kansuji

概要

漢数字の解析と変換を行うcrateである。 サポートする漢数字の桁の範囲は垓(1020)から毛(10-3)までとする (https://homepage45.net/unit/sub.htm)

なお、大字をどこまでサポートするかは今後決めるものとする。

使い方

数字と文字列との間にFromトレイトとTryFromトレイト、ToStringトレイトを元にした相互変換を実現している。 ただし、オーバーフローの関係で漢数字から数字への変換はu128およびf64, f32へのみ対応している。

use kansuji::Kansuji;

let s = "百二十三兆五百四十万二";
let kansuji = Kansuji::try_from(s).unwrap();
let n: u128 = kansuji.into();
assert_eq!(n, 123000005400002);
let kansuji2 = Kansuji::from(n);
assert_eq!(s.to_string(), kansuji2.to_string());

The MIT License

Copyright (c) 2024 Naoki Kaneko (a.k.a. "puripuri2100")