fours 0.1.0

Four in a row in your terminal, with three levels of opponent.
Documentation
use std::fmt;

/// One of the two players of a game.
///
/// [`Player::Red`] always makes the first move.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum Player {
    Red,
    Yellow,
}

impl Player {
    /// The player who makes the first move of a game.
    pub const FIRST: Self = Self::Red;

    /// The player whose turn follows this player's turn.
    ///
    /// # Examples
    ///
    /// ```
    /// use fours::game::Player;
    ///
    /// assert_eq!(Player::Red.opponent(), Player::Yellow);
    /// assert_eq!(Player::Yellow.opponent(), Player::Red);
    /// ```
    #[must_use]
    pub const fn opponent(self) -> Self {
        match self {
            Self::Red => Self::Yellow,
            Self::Yellow => Self::Red,
        }
    }

    /// The human readable name of the player.
    pub const fn name(self) -> &'static str {
        match self {
            Self::Red => "Red",
            Self::Yellow => "Yellow",
        }
    }

    /// The character that represents the player in a textual board.
    ///
    /// See [`GameState`](crate::game::GameState) for the textual board format.
    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())
    }
}