refactor: drastically simplify should_add_back_equals logic
This commit is contained in:
parent
06b6c38f30
commit
ca9a522d2b
1 changed files with 6 additions and 11 deletions
17
src/main.rs
17
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
|
||||
|
|
|
|||
Loading…
Reference in a new issue