From bb31375d2502a6829923a9a36c294c1e33654fd0 Mon Sep 17 00:00:00 2001 From: Ahurac Date: Fri, 12 Apr 2024 10:23:21 +0200 Subject: [PATCH] command_builder : suppression fonction argv inutile --- src/command/command_builder.rs | 9 ++------- src/parser.rs | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/command/command_builder.rs b/src/command/command_builder.rs index 6b409bb..69a476c 100644 --- a/src/command/command_builder.rs +++ b/src/command/command_builder.rs @@ -7,13 +7,8 @@ pub struct CommandBuilder { } impl CommandBuilder { - pub fn new() -> Self { - Self { argv: Vec::new() } - } - - pub fn argv(&mut self, argv: Vec) -> &Self { - self.argv = argv; - self + pub fn new(argv: Vec) -> Self { + Self { argv } } pub fn build(&self) -> Box { diff --git a/src/parser.rs b/src/parser.rs index 98d9831..d258fbb 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -5,7 +5,7 @@ pub fn parse_command_line(line: String) -> Option { let argv: Vec = line.split_whitespace().map(|s| s.to_string()).collect(); if !argv.is_empty() { - let command = CommandBuilder::new().argv(argv).build(); + let command = CommandBuilder::new(argv).build(); Some(CommandSequence::new(command)) } else { None