From 0ce91d44c030c5b896255955e819075ef71b5430 Mon Sep 17 00:00:00 2001 From: Max Bradbury Date: Sat, 3 Dec 2022 09:06:36 +0000 Subject: [PATCH] tidy up --- src/day_2.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/day_2.rs b/src/day_2.rs index e373530..851d994 100644 --- a/src/day_2.rs +++ b/src/day_2.rs @@ -107,11 +107,12 @@ pub fn part_2(input: &str) -> u64 { for throw in throws { let mut throw: Vec<&str> = throw.split_whitespace().take(2).collect(); - let player = throw.pop().unwrap(); + + let outcome= Outcome::from_str(throw.pop().unwrap()).unwrap(); let opponent = Move::from_str(throw.pop().unwrap()).unwrap(); - let player = match Outcome::from_str(player).unwrap() { - Outcome::Win => opponent.is_beaten_by(), + let player = match outcome { + Outcome::Win => opponent.is_beaten_by(), Outcome::Draw => opponent.clone(), Outcome::Lose => opponent.beats(), };