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.
This commit is contained in:
2026-04-02 04:16:07 +01:00
committed by oreodave
parent 1c962afb8f
commit ca07536b37
2 changed files with 18 additions and 0 deletions

1
src/modes/mod.rs Normal file
View File

@@ -0,0 +1 @@
mod single;

17
src/modes/single.rs Normal file
View File

@@ -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<Single> {
(!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)
}
}