From d74949a0d4ca9a83eca2cf59175cfb2662cdfef9 Mon Sep 17 00:00:00 2001 From: fdai7451 Date: Sat, 21 Jan 2023 16:56:43 +0100 Subject: [PATCH] refactoring: simplify main loop match break and continue arms --- src/main.rs | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/main.rs b/src/main.rs index d20e788..17cc86a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -31,9 +31,7 @@ fn main() -> Result<()> { match readline { Ok(line) => match interpret(line, &mut config, ctrlc_recv.clone()) { Ok(_) => prompt.style = config.prompt_style.clone(), - Err(ShellError::EmptyLine) => { - continue; - } + Err(ShellError::EmptyLine) => continue, Err(ShellError::NotFound(cmd)) => { eprintln!("{}: command not found", cmd.get_program().to_string_lossy()) } @@ -43,16 +41,10 @@ fn main() -> Result<()> { Err(ShellError::MalformedArgs(args)) => { eprintln!("Malformed arguments: {}", args) } - Err(ShellError::Interrupt) => { - continue; - } + Err(ShellError::Interrupt) => continue, }, - Err(ReadlineError::Interrupted) => { - continue; - } - Err(ReadlineError::Eof) => { - break; - } + Err(ReadlineError::Interrupted) => continue, + Err(ReadlineError::Eof) => break, Err(err) => { eprintln!("Error: {:?}", err); break;