mirror of
https://github.com/Steffo99/patched-porobot.git
synced 2024-12-23 01:54:22 +00:00
Make Card
s Eq
based on their Card::code
This commit is contained in:
parent
ad748c0346
commit
89a1eefd25
1 changed files with 14 additions and 2 deletions
|
@ -16,7 +16,7 @@ use super::code::CardCode;
|
||||||
/// A single Legends of Runeterra card, as represented in a `set*.json` file.
|
/// A single Legends of Runeterra card, as represented in a `set*.json` file.
|
||||||
///
|
///
|
||||||
/// The data is available in a developer-friendly interface, but nevertheless it can be serialized and deserialized via [serde] in the exact same format used in the `set*.json` files.
|
/// The data is available in a developer-friendly interface, but nevertheless it can be serialized and deserialized via [serde] in the exact same format used in the `set*.json` files.
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
#[derive(Clone, Debug, Eq, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct Card {
|
pub struct Card {
|
||||||
/// Unique seven-character identifier of the card.
|
/// Unique seven-character identifier of the card.
|
||||||
#[serde(rename = "cardCode")]
|
#[serde(rename = "cardCode")]
|
||||||
|
@ -162,7 +162,19 @@ impl Card {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Card [`Hash`]es are equal to hashes of their [`Card::code`].
|
/// Two [`Card`]s are equal if they have the same [`Card::code`].
|
||||||
|
impl PartialEq for Card {
|
||||||
|
fn eq(&self, other: &Self) -> bool {
|
||||||
|
self.code == other.code
|
||||||
|
}
|
||||||
|
|
||||||
|
fn ne(&self, other: &Self) -> bool {
|
||||||
|
self.code != other.code
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// [`Card`] [`Hash`]es are equal to hashes of their [`Card::code`].
|
||||||
impl Hash for Card {
|
impl Hash for Card {
|
||||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||||
self.code.hash(state)
|
self.code.hash(state)
|
||||||
|
|
Loading…
Reference in a new issue