diff --git a/src/parse.rs b/src/parse.rs index 7e26c35..9249956 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -5,15 +5,27 @@ pub fn arguments(args_to_process: Vec) { } fn find_operator(argument: String) -> Vec { - let mut args_with_operator = Vec::new(); - let string = Vec::new(); - for character in argument { + let mut args_with_operator: Vec = Vec::new(); + let mut string = String::new(); + for character in argument.chars() { match character { - "+" => args_with_operator.push(string.to_string()), - "-" => args_with_operator.push(string.to_string()), - "*" => args_with_operator.push(string.to_string()), - "/" => args_with_operator.push(string.to_string()), - _ => string.push(character), + '+' => { + args_with_operator.push(string.clone()); + string.clear() + } + '-' => { + args_with_operator.push(string.clone()); + string.clear() + } + '*' => { + args_with_operator.push(string.clone()); + string.clear() + } + '/' => { + args_with_operator.push(string.clone()); + string.clear() + } + _ => string.push(character.into()), } } args_with_operator