Crates.io | ph-region |
lib.rs | ph-region |
version | 0.1.0 |
source | src |
created_at | 2024-04-28 11:47:57.318721 |
updated_at | 2024-04-28 11:47:57.318721 |
description | A library for managing and utilizing administrative regions of the Philippines. |
homepage | https://github.com/codeitlikemiley/ph-region |
repository | https://github.com/codeitlikemiley/ph-region |
max_upload_size | |
id | 1223212 |
size | 18,978 |
The ph-region
Rust module provides a comprehensive way to manage and interact with a predefined set of regions, such as administrative regions in the Philippines. This module allows easy access to region details through various utility functions.
Add the following to your Cargo.toml file:
[dependencies]
ph-region = "0.1.0"
Replace "0.1.0" with the latest version of ph-region.
You can list the keys, codes, or names of all regions:
use ph_region::region::Region;
fn main() {
// Different way to List the Regions
// list of keys
println!("{:?}",Region::keys());
// list of regions abbrev name
println!("{:?}",Region::codes());
// list of region name
println!("{:?}",Region::names());
}
use ph_region::region::Region;
fn main() {
// Parse a region from a string and print it if valid
if let Some(region) = Region::from_str("ncr") {
println!("Region parsed: {:?}", region);
println!("Region name: {}", region.name());
}
// Display the full name of a region from a numeric code
if let Some(region) = Region::from_str("1") {
println!("Full name: {}", region.full_name());
}
}
use ph_region::region::Region;
fn main() {
// Display regions as code to name key-value pairs
println!("{:?}", Region::list());
// Display regions as name to code key-value pairs
println!("{:?}", Region::list_by_full_name());
}