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 {
|
pub fn parse_and_calc_humanreadable(mut input: String) -> String {
|
||||||
let should_add_back_equals = if let Some((i, _)) = input
|
let should_add_back_equals = input
|
||||||
.chars()
|
.find('=')
|
||||||
.enumerate()
|
.inspect(|i| {
|
||||||
.filter(|(_, c)| !matches!(c, ' ' | '&' | '\n'))
|
input.remove(*i);
|
||||||
.find(|(_, c)| *c == '=')
|
})
|
||||||
{
|
.is_some();
|
||||||
input.remove(i);
|
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
};
|
|
||||||
|
|
||||||
// no need to remove the characters here,
|
// no need to remove the characters here,
|
||||||
// as we ignore the them in all other logic already
|
// as we ignore the them in all other logic already
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue