amelioration du parser d'operateur
This commit is contained in:
28
src/parse.rs
28
src/parse.rs
@@ -5,15 +5,27 @@ pub fn arguments(args_to_process: Vec<String>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn find_operator(argument: String) -> Vec<String> {
|
fn find_operator(argument: String) -> Vec<String> {
|
||||||
let mut args_with_operator = Vec::new();
|
let mut args_with_operator: Vec<String> = Vec::new();
|
||||||
let string = Vec::new();
|
let mut string = String::new();
|
||||||
for character in argument {
|
for character in argument.chars() {
|
||||||
match character {
|
match character {
|
||||||
"+" => args_with_operator.push(string.to_string()),
|
'+' => {
|
||||||
"-" => args_with_operator.push(string.to_string()),
|
args_with_operator.push(string.clone());
|
||||||
"*" => args_with_operator.push(string.to_string()),
|
string.clear()
|
||||||
"/" => 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()
|
||||||
|
}
|
||||||
|
_ => string.push(character.into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
args_with_operator
|
args_with_operator
|
||||||
|
|||||||
Reference in New Issue
Block a user