use std::fmt;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum Player {
Red,
Yellow,
}
impl Player {
pub const FIRST: Self = Self::Red;
#[must_use]
pub const fn opponent(self) -> Self {
match self {
Self::Red => Self::Yellow,
Self::Yellow => Self::Red,
}
}
pub const fn name(self) -> &'static str {
match self {
Self::Red => "Red",
Self::Yellow => "Yellow",
}
}
pub const fn token(self) -> char {
match self {
Self::Red => 'R',
Self::Yellow => 'Y',
}
}
}
impl fmt::Display for Player {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str(self.name())
}
}