From 3a4559723be0fb02710682c9903b078d3d05059b Mon Sep 17 00:00:00 2001 From: primardj Date: Fri, 5 Apr 2024 23:03:54 +0100 Subject: [PATCH] change possible and cpossible in const static --- 01_phase_rust_src/sv/src/parser.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/01_phase_rust_src/sv/src/parser.rs b/01_phase_rust_src/sv/src/parser.rs index aa2a608..716011b 100644 --- a/01_phase_rust_src/sv/src/parser.rs +++ b/01_phase_rust_src/sv/src/parser.rs @@ -90,12 +90,12 @@ pub fn parse_args_1(arg: &String) -> String{ pub fn parse_args_2(arg: &String) -> String{ - let possible: Vec<&str> = vec!["start", "stop", "reload", "restart", "shutdown", "force-stop", "force-reload", "force-restart", "force-shutdown", "try-restart"]; - let cpossible: Vec = vec!['s', 'u', 'd', 'o', 'p', 'c', 'h', 'a', 'i', 'q', '1', '2', 't', 'k']; + const POSSIBLE: &'static [&'static str] = &["start", "stop", "reload", "restart", "shutdown", "force-stop", "force-reload", "force-restart", "force-shutdown", "try-restart"]; + const CPOSSIBLE: &'static [char] = &['s', 'u', 'd', 'o', 'p', 'c', 'h', 'a', 'i', 'q', '1', '2', 't', 'k']; - for var in possible.iter() { + for var in POSSIBLE.iter() { if arg == var { return var.to_string() } @@ -105,7 +105,7 @@ pub fn parse_args_2(arg: &String) -> String{ let ch1 = arg.chars().next().unwrap(); - for var in cpossible.iter() { + for var in CPOSSIBLE.iter() { if ch1 == *var { return ch1.to_string() } -- 2.45.2