Crates.io | swiss_canton |
lib.rs | swiss_canton |
version | 0.1.0 |
source | src |
created_at | 2020-05-05 17:04:34.111482 |
updated_at | 2020-05-05 17:04:34.111482 |
description | Enum for Swiss-canton-specific behaviour |
homepage | |
repository | https://gitlab.com/tobias47n9e/swiss-canton-enum |
max_upload_size | |
id | 237788 |
size | 12,030 |
Rust enum crate for Swiss-canton-specific code
You can use the enum to control something in your code:
use swiss_canton::SwissCanton;
let canton = SwissCanton::ZH;
match canton {
SwissCanton::ZH => println!("Salü!"),
SwissCanton::NE => println!("Bonjour !"),
_ => println!("Grüezi!")
}
You can also parse, compare and print the short code of the canton:
use swiss_canton::SwissCanton;
let parsed_canton = "TI".parse::<SwissCanton>().unwrap();
if (parsed_canton.eq(&SwissCanton::TI)) {
println!("Buongiorno in {}!", SwissCanton::TI);
}