From 25d354da377971c7e9783f4dec373fb6a5ce2a37 Mon Sep 17 00:00:00 2001 From: Hatmos Date: Fri, 10 Jul 2026 18:07:15 +0200 Subject: [PATCH] amelioration du parser d'operateur --- src/parse.rs | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) 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