1
0
mirror of https://github.com/danog/strum.git synced 2024-12-04 02:17:56 +01:00
strum/strum_tests/tests/enum_props.rs
Azriel Hoh 1c00f6cfa5 Feature/33/derive enum variants (#34)
* Run rustfmt over repository.

* Bump `syn` to 0.15

* Implemented ability to `serialize_all` using cases from `heck`.

Issue #21

* Use `path` and `version` in dependency specifications.

Issue #21

* Updated documentation.

Issue #21

* Added `CHANGELOG.md`.

* Also convert case when deriving `Display`.

Issue #21

* Added `EnumDiscriminants` derive.

Issue #33

* Added the ability to rename derived `EnumDiscriminants`.

Issue #33

* Updated `README.md` and lib.rs docs.

Issue #33

* Updated `CHANGELOG.md`.

Issue #33

* WIP: refactoring to allow attributes on discriminants enum.

* Use single `strum_discriminants` top level attribute.

Issue #33

* Allow multiple declarations of `strum_discriminants` attribute.

Issue #33

* Pass through all other attributes to discriminant enum.

Issue #33

* Add `impl From<MyEnum> for MyEnumDiscriminants`.

Issue #33

* Add `impl<'_enum> From<&'_enum MyEnum> for MyEnumDiscriminants`.

Issue #33

* Added complex case test for `From` derivation.

Issue #33

* Added docs to some helper functions.

* Added docs about `From` impls.

Issue #33
2018-09-26 12:13:45 -07:00

31 lines
488 B
Rust

extern crate strum;
#[macro_use]
extern crate strum_macros;
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"));
}