From ca07536b3786c09485f2be5eb3158c918896fdad Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Thu, 2 Apr 2026 04:16:07 +0100 Subject: [PATCH] modes: new crate representing the API for different round types Single is our first one - trivial really. Only thing we need to check is that the single isn't made up of a joker. --- src/modes/mod.rs | 1 + src/modes/single.rs | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 src/modes/mod.rs create mode 100644 src/modes/single.rs diff --git a/src/modes/mod.rs b/src/modes/mod.rs new file mode 100644 index 0000000..2fdacdc --- /dev/null +++ b/src/modes/mod.rs @@ -0,0 +1 @@ +mod single; diff --git a/src/modes/single.rs b/src/modes/single.rs new file mode 100644 index 0000000..4448106 --- /dev/null +++ b/src/modes/single.rs @@ -0,0 +1,17 @@ +use crate::card::Card; + +#[derive(PartialEq, Eq, PartialOrd, Ord, Debug, Copy, Clone)] +pub struct Single(Card); + +impl Single { + fn new(c: Card) -> Option { + (!c.is_joker()).then_some(Single(c)) + } +} + +use std::fmt::{Display, Formatter, Result}; +impl Display for Single { + fn fmt(&self, f: &mut Formatter<'_>) -> Result { + write!(f, "Single({})", self.0) + } +}