sashite_pin/side.rs
1//! Piece side: the camp a piece belongs to.
2
3/// The camp a piece belongs to.
4///
5/// In PIN, the *case* of the abbreviation letter encodes the side: an
6/// uppercase letter (`A`–`Z`) denotes [`Side::First`], a lowercase letter
7/// (`a`–`z`) denotes [`Side::Second`]. This mirrors the two-side model of the
8/// [glossary](https://sashite.dev/glossary/): a side is a pure label
9/// (`first` / `second`) that acquires meaning only once a rule system assigns
10/// it to a player or piece.
11#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
12#[repr(u8)]
13pub enum Side {
14 /// The `first` side, encoded by an uppercase letter (`A`–`Z`).
15 First = 0,
16 /// The `second` side, encoded by a lowercase letter (`a`–`z`).
17 Second = 1,
18}
19
20impl Side {
21 /// Returns the opposite side.
22 ///
23 /// # Examples
24 ///
25 /// ```
26 /// use sashite_pin::Side;
27 ///
28 /// assert_eq!(Side::First.flip(), Side::Second);
29 /// assert_eq!(Side::Second.flip(), Side::First);
30 /// ```
31 #[must_use]
32 pub const fn flip(self) -> Self {
33 match self {
34 Self::First => Self::Second,
35 Self::Second => Self::First,
36 }
37 }
38}