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

Add SpellSpeed::Unsupported and #[non_exaustive]

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

View file

@ -3,6 +3,7 @@
use crate::data::corebundle::speed::{LocalizedSpellSpeed, LocalizedSpellSpeedIndex};
/// A possible [`Spell`](super::type::CardType::Spell) speed.
#[non_exhaustive]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
pub enum SpellSpeed {
/// Non-spell cards have this speed.
@ -14,6 +15,9 @@ pub enum SpellSpeed {
Fast,
/// Either a Burst or a Focus spell; to disambiguate between the two, check for the `Focus` keyword.
Burst,
/// Unsupported spell speed.
#[serde(other)]
Unsupported,
}
impl SpellSpeed {
@ -50,9 +54,5 @@ mod tests {
test_deserialization!(deserialize_slow, r#""Slow""#, SpellSpeed::Slow);
test_deserialization!(deserialize_fast, r#""Fast""#, SpellSpeed::Fast);
test_deserialization!(deserialize_burst, r#""Burst""#, SpellSpeed::Burst);
#[test]
fn deserialize_fallback() {
assert!(serde_json::de::from_str::<'static, SpellSpeed>("Xyzzy").is_err());
}
test_deserialization!(deserialize_unsupported, r#""Xyzzy""#, SpellSpeed::Unsupported);
}