From b7a9b3e1cad339a79764b0c21a3f79fe61473fcc Mon Sep 17 00:00:00 2001 From: atomflunder <80397293+atomflunder@users.noreply.github.com> Date: Tue, 15 Nov 2022 17:25:29 +0100 Subject: [PATCH] Refactor if statements --- src/uscf.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/uscf.rs b/src/uscf.rs index 89f3932..b2bc4ee 100644 --- a/src/uscf.rs +++ b/src/uscf.rs @@ -222,8 +222,8 @@ pub fn uscf( player_one.games, 1, player_two.rating, - if outcome == &Outcomes::WIN { 1 } else { 0 }, - if outcome == &Outcomes::LOSS { 1 } else { 0 }, + i32::from(outcome == &Outcomes::WIN), + i32::from(outcome == &Outcomes::LOSS), ) } else { new_rating( @@ -242,8 +242,8 @@ pub fn uscf( player_two.games, 1, player_one.rating, - if outcome == &Outcomes::LOSS { 1 } else { 0 }, - if outcome == &Outcomes::WIN { 1 } else { 0 }, + i32::from(outcome == &Outcomes::LOSS), + i32::from(outcome == &Outcomes::WIN), ) } else { new_rating( @@ -337,12 +337,12 @@ pub fn uscf_rating_period( let wins = results .iter() - .map(|r| if r.1 == Outcomes::WIN { 1 } else { 0 }) + .map(|r| i32::from(r.1 == Outcomes::WIN)) .sum(); let losses = results .iter() - .map(|r| if r.1 == Outcomes::LOSS { 1 } else { 0 }) + .map(|r| i32::from(r.1 == Outcomes::LOSS)) .sum(); let new_rating = new_rating_provisional(