pub enum RPS {
Rock,
Paper,
Scissors,
}
Expand description
The move in the game RPS
.
Variants§
Implementations§
Trait Implementations§
source§impl Neg for &RPS
impl Neg for &RPS
Negation of an RPS move is defined as the following.
Let move a
be Rock
. -a
is the opposite of a
defining a > -a
or inversely -a < a
.
This implies -a
to be Scissors to make the above statement true
.
Example
defining Paper < Scissors = Paper = -Scissors
assert_eq!(RPS::Paper, -RPS::Scissors)
source§impl Ord for RPS
impl Ord for RPS
Compares two RPS moves against each other to see which will win.
self > other
implies that self wins
over other
Example
assert!(RPS::Rock > RPS::Scissors);
assert!(RPS::Paper < RPS::Scissors);
assert!(RPS::Rock < RPS::Paper);
source§impl PartialOrd<RPS> for RPS
impl PartialOrd<RPS> for RPS
Compares two moves against each other to see who would win.
See Ord for more details.
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl TryFrom<&str> for RPS
impl TryFrom<&str> for RPS
Converts a string into a move associated with RPS.
See TryFrom char for more details.
source§impl TryFrom<char> for RPS
impl TryFrom<char> for RPS
Converts a character into a move associated with RPS.
Valid characters are
A or X = Rock
B or Y = Paper
C or Z = Scissors
impl Copy for RPS
impl Eq for RPS
impl StructuralEq for RPS
impl StructuralPartialEq for RPS
Auto Trait Implementations§
impl RefUnwindSafe for RPS
impl Send for RPS
impl Sync for RPS
impl Unpin for RPS
impl UnwindSafe for RPS
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