helper: ordered now takes a fixed sized array of type T

I wanted to abstract ordered to any size instead of just binary
tuples - but tuples have a strange issue where you can't be generic
about them past like a limit of 12.  With this setup, ordered takes
ownership of some fixed array, sorts it, then returns it back.

modes:pair and modes:single have been refactored to utilise this new
form of ordered - it's basically the exact same in these cases.
This commit is contained in:
2026-04-03 23:56:22 +01:00
committed by oreodave
parent f8f5c12316
commit 892c112433
2 changed files with 5 additions and 6 deletions

View File

@@ -15,7 +15,7 @@ impl Pair {
fn new(c1: Card, c2: Card) -> Option<Pair> {
// Order the cards. This means if xor(c1 is joker, c2 is joker) c1 will
// be that joker.
let (c1, c2) = ordered(c1, c2);
let [c1, c2] = ordered([c1, c2]);
match (c1, c2) {
// Can't be a pair if you got two jokers homie.
@@ -192,7 +192,7 @@ mod tests {
})
.for_each(|(c1, c2, pair)| {
// TEST: Pairs always sort their cards in strength.
let (b1, b2) = ordered(c1, c2);
let [b1, b2] = ordered([c1, c2]);
assert_eq!(pair.0, b1, "Expected {} to be {b1}", pair.0);
assert_eq!(pair.1, b2, "Expected {} to be {b2}", pair.1);
});