two_player/player.rs
1#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2pub enum Player {
3 FirstPlayer,
4 SecondPlayer,
5}
6
7impl Player {
8 pub fn is_first(self) -> bool {
9 self == Player::FirstPlayer
10 }
11
12 pub fn is_second(self) -> bool {
13 self == Player::SecondPlayer
14 }
15
16 pub fn opposite(self) -> Player {
17 match self {
18 Player::FirstPlayer => Player::SecondPlayer,
19 Player::SecondPlayer => Player::FirstPlayer,
20 }
21 }
22}