#control

swiss_canton

Enum for Swiss-canton-specific behaviour

1 unstable release

0.1.0 May 5, 2020

#355 in #control

MIT license

11KB
127 lines

Swiss Canton Enum

Rust enum crate for Swiss-canton-specific code

Example

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);
}

lib.rs:

Swiss canton enum

A crate that can help your code do canton-specific things

Example

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);
}

Dependencies

~65KB