From 1370ba9374238e618a7dd070e68ef28e262288ee Mon Sep 17 00:00:00 2001 From: fdai7375 Date: Thu, 2 Feb 2023 21:06:13 +0100 Subject: [PATCH] refactoring: fix clippy warnings in logout execute function --- src/builtins/logout.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/builtins/logout.rs b/src/builtins/logout.rs index dc5aee6..ce3a450 100644 --- a/src/builtins/logout.rs +++ b/src/builtins/logout.rs @@ -9,13 +9,17 @@ impl Builtin for Logout { fn execute(&mut self, _: &mut BuiltinConfig, _: Vec) -> Result<(), ShellError> { let mut input_confirmation = String::new(); println!("Are you sure? Unsaved data will be lost.\ny/n"); - io::stdin().read_line(&mut input_confirmation).expect("Couldn't read form stdin"); - if input_confirmation.chars().next().unwrap() == 'y' { + io::stdin() + .read_line(&mut input_confirmation) + .expect("Couldn't read form stdin"); + if input_confirmation.starts_with('y') { match logout() { Ok(_) => println!("Logging out"), - Err(error) => eprintln!("Failed to log out: {}", error), + Err(error) => eprintln!("Failed to log out: {error}"), } - } else { println!("Aborting"); } + } else { + println!("Aborting"); + } Ok(()) } -} \ No newline at end of file +}