jp-prefecture is an utility library for handling Japanese prefectures.
Crate has to be added as dependency to Cargo.toml
toml
[dependencies]
jp-prefecture = "3.0.0"
and imported to the scope of a block where it's begin called
rust
use jp_prefecture::prefectures;
```rust use jp_prefecture::prefectures;
let tokyo = prefectures::findbykanji("東京都"); println!("{:?}", tokyo); // => Ok(Prefecture::Tokyo) println!("{:?}", tokyo.asref().unwrap().kanji()); // => "東京都" println!("{:?}", tokyo.asref().unwrap().kanjishort()); // => "東京" println!("{:?}", tokyo.asref().unwrap().english()); // => "Tokyo"
let tokyo = prefectures::findbykanji("東京県"); // uhmmmm... println!("{:?}", tokyo); // => Err(Error::InvalidPrefectureName("東京県")) ```