You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm pretty new to rust and decided to implement my own magic the gathering implementation so i have to match a bunch of different cases and stuff and some of this isn't behaving how I'm expecting it to, so i just want to sanity check:
#[derive(Debug,PartialEq,EnumString,Clone,Hash,Eq,VariantNames,VariantArray)]#[strum(serialize_all="lowercase")]enumColor{#[strum(serialize="G", serialize="{green}", ascii_case_insensitive)]Green}#[cfg(test)]mod tests {usesuper::*;#[test]fncolor_accepts_lowercase(){// <----- This test fails. but.. should it? because i'm serializing all to lowercase AND using case insensitivitylet _green = Color::Green;let green = Color::from_str("green");assert_eq!(_green, green.unwrap());// <-- called `Result::unwrap()` on an `Err` value: VariantNotFound}#[test]fncolor_accepts_single_letter(){let green = Color::Green;let g = Color::from_str("g");assert_eq!(green, g.unwrap());}#[test]fncolor_accepts_single_letter_uppercase(){let green = Color::Green;letG = Color::from_str("G");assert_eq!(green, G.unwrap());}#[test]fncolor_accepts_brackets(){let green = Color::Green;letG = Color::from_str("{green}");assert_eq!(green, G.unwrap());}}
All the other tests work fine, but I'm also a bit confused by the Color::VARIANTS behavior-
I assumed that it would be ALL of the at least named variants-
So...
Green, G, {green}
but for some reason if i println it, i only get:
["{green}", ascii_case_insensitive]
but all my tests pass. Is that the expected behavior for the Color::VARIANTS?
The text was updated successfully, but these errors were encountered:
I'm pretty new to rust and decided to implement my own magic the gathering implementation so i have to match a bunch of different cases and stuff and some of this isn't behaving how I'm expecting it to, so i just want to sanity check:
All the other tests work fine, but I'm also a bit confused by the Color::VARIANTS behavior-
I assumed that it would be ALL of the at least named variants-
So...
Green, G, {green}
but for some reason if i println it, i only get:
["{green}", ascii_case_insensitive]
but all my tests pass. Is that the expected behavior for the Color::VARIANTS?
The text was updated successfully, but these errors were encountered: