From 2ed92df37474f8c155ff5c7878832f413c17a69a Mon Sep 17 00:00:00 2001 From: fdai7451 Date: Sat, 21 Jan 2023 15:43:22 +0100 Subject: [PATCH] refactoring: use String instead of &str in interpret --- src/execute.rs | 4 ++-- src/main.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/execute.rs b/src/execute.rs index d48f58d..92f000f 100644 --- a/src/execute.rs +++ b/src/execute.rs @@ -5,11 +5,11 @@ use crate::builtins::{execute_builtin, is_builtin}; use crate::error::ShellError; use crate::parse::parse_line; -pub fn interpret(line: &str) -> Result<(), ShellError> { +pub fn interpret(line: String) -> Result<(), ShellError> { if line.is_empty() { return Err(ShellError::EmptyLine); } - let (keyword, args) = parse_line(line)?; + let (keyword, args) = parse_line(&line)?; if is_builtin(keyword) { execute_builtin(keyword, args)?; diff --git a/src/main.rs b/src/main.rs index 61298e6..76c24d1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,7 +20,7 @@ fn main() -> Result<()> { let readline = rl.readline(&prompt.get_prompt()); match readline { - Ok(line) => match interpret(&line) { + Ok(line) => match interpret(line) { Ok(_) => {} Err(ShellError::EmptyLine) => { continue;