cargo.toml
[dependencies]
str_to_enum_derive = "0.2.0"
main.rs
#[macro_use]
extern crate str_to_enum_derive;
#[derive(StrToEnum, Debug, PartialEq, Eq)]
enum HTTPMethod {
GET,
HEAD,
POST,
PUT,
DELETE,
CONNECT,
OPTIONS,
TRACE
}
fn main() {
assert_eq!(HTTPMethod::GET, "GET".parse::<HTTPMethod>().unwrap());
assert_eq!(HTTPMethod::HEAD, "HEAD".parse::<HTTPMethod>().unwrap());
}
- attribute
value
- attribute
case
(with heck) - attribute
case_insensitive
[dependencies]
str_to_enum_derive = { version = "*", features = ["fxhasher"] }
Replace DefaultHasher with FxHasher
Maintained in CHANGELOG.MD