Skip to content

Commit

Permalink
Refactor if statements
Browse files Browse the repository at this point in the history
  • Loading branch information
atomflunder committed Nov 15, 2022
1 parent e809cdd commit b7a9b3e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/uscf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit b7a9b3e

Please sign in to comment.