diff --git a/src/card/hash.rs b/src/card/hash.rs index 84f7840..7457f12 100644 --- a/src/card/hash.rs +++ b/src/card/hash.rs @@ -1,6 +1,26 @@ -use crate::card::Card; +use crate::card::{Card, PlayingCard, Rank, Suit}; use std::hash::{Hash, Hasher}; +impl Hash for Rank { + fn hash(&self, state: &mut H) { + (*self as i64).hash(state); + } +} + +impl Hash for Suit { + fn hash(&self, state: &mut H) { + (*self as i64).hash(state); + } +} + +impl Hash for PlayingCard { + fn hash(&self, state: &mut H) { + // NOTE: We're using the i64 conversion of card for the hash since that + // should generate unique numbers per card. + i64::from(*self).hash(state); + } +} + impl Hash for Card { fn hash(&self, state: &mut H) { // NOTE: We're using the i64 conversion of card for the hash since that