1
0
mirror of https://github.com/danog/strum.git synced 2024-12-02 17:38:15 +01:00
strum/strum_tests/tests/enum_props.rs
Jonas Platte b517f232aa
Update strum to Rust edition 2018 (#110)
* Set all crates to edition 2018

* Remove redundant imports

* Remove extern crate declarations for cargo dependencies
2020-09-17 11:21:21 -07:00

27 lines
427 B
Rust

use strum::EnumProperty;
#[derive(Debug, EnumProperty)]
enum Test {
#[strum(props(key = "value"))]
A,
B,
}
#[test]
fn prop_test() {
let a = Test::A;
assert_eq!("value", a.get_str("key").unwrap());
}
#[test]
fn prop_test_not_found() {
let a = Test::A;
assert_eq!(None, a.get_str("Not Found"));
}
#[test]
fn prop_test_not_found_2() {
let b = Test::B;
assert_eq!(None, b.get_str("key"));
}