1
0
mirror of https://github.com/danog/strum.git synced 2024-12-11 08:59:37 +01:00
strum/strum_tests/tests/as_ref_no_strum.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

34 lines
661 B
Rust

use strum_macros::AsRefStr;
#[derive(Debug, Eq, PartialEq, AsRefStr)]
enum Color {
#[strum(to_string = "RedRed")]
Red,
#[strum(serialize = "b", to_string = "blue")]
Blue { hue: usize },
#[strum(serialize = "y", serialize = "yellow")]
Yellow,
#[strum(default)]
Green(String),
}
#[test]
fn as_red_str() {
assert_eq!("RedRed", (Color::Red).as_ref());
}
#[test]
fn as_blue_str() {
assert_eq!("blue", (Color::Blue { hue: 0 }).as_ref());
}
#[test]
fn as_yellow_str() {
assert_eq!("yellow", (Color::Yellow).as_ref());
}
#[test]
fn as_green_str() {
assert_eq!("Green", (Color::Green(String::default())).as_ref());
}