jp-prefecture

Crates.iojp-prefecture
lib.rsjp-prefecture
version3.1.0
sourcesrc
created_at2022-04-07 15:51:48.756936
updated_at2023-04-02 13:15:55.882722
descriptionan utility crate of using Japanese prefectures
homepage
repositoryhttps://github.com/itto-ki/jp-prefecture
max_upload_size
id563736
size82,887
nyx (github:styx-rs:nyx)

documentation

https://docs.rs/jp-prefecture/latest/jp_prefecture/

README

Crates.io Docs.rs Crates.io Test

jp-prefecture

jp-prefecture is an utility library for handling Japanese prefectures.

Getting Started

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;

Examples

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("東京県"))
Commit count: 71

cargo fmt