pub struct Player(/* private fields */);Expand description
Player index – 0, 1, 2, 3 => player assigned east, south, west, north in the initial round.
This is forced to mod-4 arithmetic, and can represent both the absolute player index or the difference between player indices (“relative player”).
Reason for reinventing the wheel instead of using ux, bare_metal_modulo etc.:
This is trivial, and these don’t support serde.
§Optional serde support
Serializes as the player index number (0/1/2/3). Deserialization will check the range.
Implementations§
Source§impl Player
impl Player
pub const fn new(x: u8) -> Self
pub const fn add(self, other: Player) -> Player
pub const fn add_u8(self, other: u8) -> Player
pub const fn sub(self, other: Player) -> Player
pub const fn sub_u8(self, other: u8) -> Player
pub const fn to_u8(self) -> u8
pub const fn to_usize(self) -> usize
Sourcepub const fn succ(self) -> Self
pub const fn succ(self) -> Self
Returns the player 1 turn after me, a.k.a. Successor, Shimocha (下家). In a physical game, said player would sit to the right of me (CCW).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Player
impl<'de> Deserialize<'de> for Player
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Copy for Player
impl Eq for Player
impl StructuralPartialEq for Player
Auto Trait Implementations§
impl Freeze for Player
impl RefUnwindSafe for Player
impl Send for Player
impl Sync for Player
impl Unpin for Player
impl UnwindSafe for Player
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more