1
Fork 0
mirror of https://github.com/Steffo99/patched-porobot.git synced 2024-12-23 01:54:22 +00:00

Add CardRarity::Unsupported and #[non_exaustive]

This commit is contained in:
Steffo 2023-10-22 23:05:23 +02:00
parent e9e051b72e
commit 7041b75d2f
Signed by: steffo
GPG key ID: 2A24051445686895

View file

@ -3,6 +3,7 @@
use crate::data::corebundle::rarity::{LocalizedCardRarity, LocalizedCardRarityIndex};
/// A possible [Card](super::card::Card) rarity.
#[non_exhaustive]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
pub enum CardRarity {
/// The card has no rarity, as it probably is not [collectible](super::card::Card::collectible).
@ -19,6 +20,10 @@ pub enum CardRarity {
/// A champion (orange hexagon) card, sometimes referred to as *Legendary*.
Champion,
/// Unsupported rarity.
#[serde(other)]
Unsupported,
}
impl CardRarity {
@ -56,9 +61,5 @@ mod tests {
test_deserialization!(deserialize_rare, r#""Rare""#, CardRarity::Rare);
test_deserialization!(deserialize_epic, r#""Epic""#, CardRarity::Epic);
test_deserialization!(deserialize_champion, r#""Champion""#, CardRarity::Champion);
#[test]
fn deserialize_fallback() {
assert!(serde_json::de::from_str::<'static, CardRarity>("Xyzzy").is_err());
}
test_deserialization!(deserialize_unsupported, r#""Xyzzy""#, CardRarity::Unsupported);
}