#[repr(u8)] pub enum Play { Rock, Paper, Scissors, } impl Into for Play { fn into(self) -> char { match self { Play::Rock => 'X', Play::Paper => 'Y', Play::Scissors => 'Z', } } } impl Into for Play { fn into(self) -> i32 { match self { Play::Rock => 1, Play::Paper => 2, Play::Scissors => 3, } } } pub fn translate(letter: char) -> Option { match letter { 'A' => Some(Play::Rock), 'B' => Some(Play::Paper), 'C' => Some(Play::Scissors), _ => None, } } pub fn winning(play: Play) -> char { match play { Play::Rock => Play::Paper.into(), Play::Paper => Play::Scissors.into(), Play::Scissors => Play::Rock.into(), } }