From 94bcf5b59b56843c679d2ae7bdf21697150f3dba Mon Sep 17 00:00:00 2001 From: "Dr. Dystopia" Date: Thu, 12 Aug 2021 12:34:04 +0200 Subject: [PATCH] Move assignment out of if-statement --- common/src/comp/combo.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/common/src/comp/combo.rs b/common/src/comp/combo.rs index 0de0e922c9..b04f460b86 100644 --- a/common/src/comp/combo.rs +++ b/common/src/comp/combo.rs @@ -27,11 +27,11 @@ impl Combo { pub fn reset(&mut self) { self.counter = 0; } pub fn change_by(&mut self, amount: i32, time: f64) { - if amount > 0 { - self.counter = self.counter.saturating_add(amount as u32); + self.counter = if amount > 0 { + self.counter.saturating_add(amount as u32) } else { - self.counter = self.counter.saturating_sub(amount.abs() as u32); - } + self.counter.saturating_sub(amount.abs() as u32) + }; self.last_increase = time; } }