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,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);
|
||||
}
|
||||
Reference in new issue
Block a user