modes:mod|single: fix issue with footstool not taking other by reference

This commit is contained in:
2026-04-02 05:46:45 +01:00
committed by oreodave
parent e401819914
commit 71f644043a
2 changed files with 9 additions and 9 deletions

View File

@@ -9,7 +9,7 @@ pub enum Footstool {
} }
pub trait Hand { pub trait Hand {
fn footstool(&self, other: Self) -> Footstool; fn footstool(&self, other: &Self) -> Footstool;
} }
mod tests { mod tests {
@@ -22,8 +22,8 @@ mod tests {
x: &T, x: &T,
y: &T, y: &T,
) -> (Footstool, Footstool) { ) -> (Footstool, Footstool) {
let res1 = x.footstool(*y); let res1 = x.footstool(y);
let res2 = y.footstool(*x); let res2 = y.footstool(x);
assert!(match (res1, res2) { assert!(match (res1, res2) {
(Footstool::None, Footstool::None) (Footstool::None, Footstool::None)
| (Footstool::None, Footstool::Half) | (Footstool::None, Footstool::Half)

View File

@@ -12,7 +12,7 @@ impl Single {
use crate::modes::{Footstool, Hand}; use crate::modes::{Footstool, Hand};
impl Hand for Single { impl Hand for Single {
fn footstool(&self, other: Self) -> Footstool { fn footstool(&self, other: &Self) -> Footstool {
let self_abs = self.0.deck_abs(); let self_abs = self.0.deck_abs();
let other_abs = other.0.deck_abs(); let other_abs = other.0.deck_abs();
@@ -76,7 +76,7 @@ mod tests {
(single_slice[0], single_slice[1], single_slice[2]); (single_slice[0], single_slice[1], single_slice[2]);
// A single is always full footstooled by itself // A single is always full footstooled by itself
assert!(s1.footstool(s1) == Footstool::Full); assert!(s1.footstool(&s1) == Footstool::Full);
// Test general non-reflexivity of the footstool relation and get // Test general non-reflexivity of the footstool relation and get
// back some results we'd like to verify further. // back some results we'd like to verify further.
@@ -152,10 +152,10 @@ mod tests {
let piv_after = Single(Card::from(i64::from(piv_copy.0) + 1)); let piv_after = Single(Card::from(i64::from(piv_copy.0) + 1));
let piv_way_after = Single(Card::from(i64::from(piv_copy.0) + 2)); let piv_way_after = Single(Card::from(i64::from(piv_copy.0) + 2));
assert!(pivot.footstool(piv_copy) == Footstool::Full); assert!(pivot.footstool(&piv_copy) == Footstool::Full);
assert!(pivot.footstool(piv_before) == Footstool::Half); assert!(pivot.footstool(&piv_before) == Footstool::Half);
assert!(piv_after.footstool(pivot) == Footstool::Half); assert!(piv_after.footstool(&pivot) == Footstool::Half);
assert!(pivot.footstool(piv_way_after) == Footstool::None); assert!(pivot.footstool(&piv_way_after) == Footstool::None);
} }
} }
} }