Crates.io | jp-prefecture |
lib.rs | jp-prefecture |
version | 3.1.0 |
source | src |
created_at | 2022-04-07 15:51:48.756936 |
updated_at | 2023-04-02 13:15:55.882722 |
description | an utility crate of using Japanese prefectures |
homepage | |
repository | https://github.com/itto-ki/jp-prefecture |
max_upload_size | |
id | 563736 |
size | 82,887 |
jp-prefecture is an utility library for handling Japanese prefectures.
Crate has to be added as dependency to Cargo.toml
[dependencies]
jp-prefecture = "3.1.0"
and imported to the scope of a block where it's begin called
use jp_prefecture::prefectures;
use jp_prefecture::prefectures;
let tokyo = prefectures::find_by_kanji("東京都");
println!("{:?}", tokyo); // => Ok(Prefecture::Tokyo)
println!("{:?}", tokyo.as_ref().unwrap().kanji()); // => "東京都"
println!("{:?}", tokyo.as_ref().unwrap().kanji_short()); // => "東京"
println!("{:?}", tokyo.as_ref().unwrap().english()); // => "Tokyo"
let tokyo = prefectures::find_by_kanji("東京県"); // uhmmmm...
println!("{:?}", tokyo); // => Err(Error::InvalidPrefectureName("東京県"))