Hello,
I want to be able to put this struct inside a hashset, in order to only store unique instances. However, I have my own definition of unique...
#[derive(Eq, Debug)]
struct PossibilityReport {
place: (InventoryIdx, BoardIdx),
piece: (PieceIdx, RotationIdx),
next: BoardIdx,
}
impl PartialEq for PossibilityReport {
fn eq(&self, other: &Self) -> bool {
self.piece.0 == other.piece.0
&& Side::from(other.piece.1).to_opposite().to_usize() == self.piece.1
&& self.next == other.next
}
}
I'm a bit confused as to how I should impl Hash
on this struct? I Because I thought it's the hash that determines whether something is unique, so should my equality check be included in the hashing somehow?
Looking for some guidance on how Hash and Eq work together.
Thanks!