fn parse_after_whitespace(char_splitted_command_line: &mut Vec, argv: &mut Vec) -> Vec { let current_char_option = char_splitted_command_line.pop(); if current_char_option.is_none() { argv.to_vec() } else { let current_char = current_char_option.unwrap(); if current_char.is_whitespace() { parse_after_whitespace(char_splitted_command_line, argv) } else { parse_initial_state(char_splitted_command_line, &mut String::from(current_char.to_string()), argv) } } } fn parse_initial_state(char_splitted_command_line: &mut Vec, current_arg: &mut String, argv: &mut Vec) -> Vec { let current_char_option = char_splitted_command_line.pop(); if current_char_option.is_none() { argv.push(current_arg.to_string()); argv.to_vec() } else { let current_char = current_char_option.unwrap(); if current_char.is_whitespace() { argv.push(current_arg.to_string()); parse_after_whitespace(char_splitted_command_line, argv) } else { current_arg.push(current_char); parse_initial_state(char_splitted_command_line, current_arg, argv) } } } fn split_string_in_chars(string_to_split: &String) -> Vec { string_to_split.trim().chars().rev().collect() } pub fn parse(command_line: &String) -> Vec { let mut argv: Vec = Vec::new(); let mut char_splitted_command_line: Vec = split_string_in_chars(&command_line); let mut new_arg = String::new(); argv = parse_initial_state(&mut char_splitted_command_line, &mut new_arg, &mut argv); argv }