2 个不稳定版本
使用旧的Rust 2015
0.2.0 | 2018年1月21日 |
---|---|
0.1.0 | 2017年9月16日 |
在 #ref 中排名 40
4KB
示例
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());
}
依赖项
~2MB
~47K SLoC