From ca9a522d2b5ad1a5b2c2002e405cedb4fd8444de Mon Sep 17 00:00:00 2001 From: electria Date: Tue, 29 Sep 2026 16:17:32 -0700 Subject: [PATCH] refactor: drastically simplify should_add_back_equals logic --- src/main.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/main.rs b/src/main.rs index fbb3a72..a8f98ac 100644 --- a/src/main.rs +++ b/src/main.rs @@ -22,17 +22,12 @@ fn main() { } pub fn parse_and_calc_humanreadable(mut input: String) -> String { - let should_add_back_equals = if let Some((i, _)) = input - .chars() - .enumerate() - .filter(|(_, c)| !matches!(c, ' ' | '&' | '\n')) - .find(|(_, c)| *c == '=') - { - input.remove(i); - true - } else { - false - }; + let should_add_back_equals = input + .find('=') + .inspect(|i| { + input.remove(*i); + }) + .is_some(); // no need to remove the characters here, // as we ignore the them in all other logic already