server/domain/players/
pone.rs1use serde::{Deserialize, Serialize};
2
3use super::{Dealer, Player};
4
5#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
10#[repr(transparent)]
11#[serde(transparent)]
12pub struct Pone(Player);
13
14impl Pone {
15 #[must_use]
17 pub const fn player(&self) -> Player {
18 self.0
19 }
20
21 #[must_use]
23 pub fn opponent(&self) -> Dealer {
24 Dealer::from(self.0.opponent())
25 }
26}
27
28impl<T> std::ops::Index<Pone> for [T] {
29 type Output = T;
30
31 fn index(&self, index: Pone) -> &Self::Output {
32 &self[index.0]
33 }
34}
35
36impl<T> std::ops::Index<&Pone> for [T] {
37 type Output = T;
38
39 fn index(&self, index: &Pone) -> &Self::Output {
40 &self[index.0]
41 }
42}
43
44impl From<Player> for Pone {
45 fn from(value: Player) -> Self {
46 Self(value)
47 }
48}
49
50impl std::fmt::Display for Pone {
51 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
52 write!(f, "Pone({})", self.0)
53 }
54}