amelioration du parser d'operateur

This commit is contained in:
2026-07-10 18:07:15 +02:00
parent 4b7c4a4a73
commit 25d354da37

View File

@@ -5,15 +5,27 @@ pub fn arguments(args_to_process: Vec<String>) {
}
fn find_operator(argument: String) -> Vec<String> {
let mut args_with_operator = Vec::new();
let string = Vec::new();
for character in argument {
let mut args_with_operator: Vec<String> = 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