Project restructuring, dedicated traits, TryScribeString derive
This commit is contained in:
1 parent
6a2ffc19eb
commit
0c4c252be9
14 files changed
+245
-119
No files matched your search
@@ -0,0 +1,10 @@
|
||||
[package]
|
||||
name = "enumscribe_examples"
|
||||
version = "0.1.0"
|
||||
authors = ["Tom Panton <pantonshire@gmail.com>"]
|
||||
edition = "2018"
|
||||
license = "MIT"
|
||||
|
||||
[dev-dependencies]
|
||||
enumscribe = { path = "../enumscribe" }
|
||||
enumscribe_derive = { path = "../enumscribe_derive" }
|
||||
@@ -0,0 +1,22 @@
|
||||
use enumscribe::*;
|
||||
|
||||
// #[derive(ScribeString)]
|
||||
#[derive(TryScribeString)]
|
||||
enum Airport {
|
||||
#[enumscribe(str = "LHR", case_insensitive)]
|
||||
Heathrow,
|
||||
#[enumscribe(str = "LGW", case_insensitive)]
|
||||
Gatwick,
|
||||
#[enumscribe(str = "LTN", case_insensitive)]
|
||||
Luton,
|
||||
#[enumscribe(str = "BHX", case_insensitive, ignore)]
|
||||
BirminghamInternational,
|
||||
#[enumscribe(other)]
|
||||
Other(String),
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let luton = Airport::Luton;
|
||||
let luton_string = luton.try_scribe();
|
||||
println!("Hello, {:?}!", luton_string);
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
Reference in new issue
Block a user