1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
use strum_macros::{EnumIter, EnumString, IntoStaticStr};
#[derive(Debug, Hash, Clone, Copy, PartialEq, Eq, EnumString, IntoStaticStr, EnumIter)]
#[allow(missing_docs)]
pub enum StateProv {
AL,
AK,
AZ,
AR,
CA,
CO,
CT,
DE,
FL,
GA,
HI,
ID,
IL,
IN,
IA,
KS,
KY,
LA,
ME,
MD,
MA,
MI,
MN,
MS,
MO,
MT,
NE,
NV,
NH,
NJ,
NM,
NY,
NC,
ND,
OH,
OK,
OR,
PA,
RI,
SC,
SD,
TN,
TX,
UT,
VT,
VA,
WA,
WV,
WI,
WY,
AS,
DC,
FM,
MH,
MP,
PW,
PR,
VI,
}
impl StateProv {
pub fn as_static_str(self) -> &'static str {
self.into()
}
}
#[cfg(test)]
mod unit {
use super::*;
use std::str::FromStr;
use strum::IntoEnumIterator;
#[test]
fn test_to_string_for_state_prov() {
assert_eq!(StateProv::AL.as_static_str(), "AL");
}
#[test]
fn test_from_string_for_state_prov() {
assert_eq!(StateProv::from_str("AL").unwrap(), StateProv::AL);
}
#[test]
fn round_trip_strings_for_state_prov() {
for state_prov in StateProv::iter() {
assert_eq!(
StateProv::from_str(state_prov.as_static_str()).unwrap(),
state_prov
);
}
}
}