Browse Source

fix: change expect to match statement

main
fdai7375 2 years ago
parent
commit
29075f7e54
  1. 11
      src/builtins/logout.rs

11
src/builtins/logout.rs

@ -9,9 +9,14 @@ impl Builtin for Logout {
fn execute(&mut self, _: &mut BuiltinConfig, _: Vec<String>) -> Result<(), ShellError> { fn execute(&mut self, _: &mut BuiltinConfig, _: Vec<String>) -> Result<(), ShellError> {
let mut input_confirmation = String::new(); let mut input_confirmation = String::new();
println!("Are you sure? Unsaved data will be lost.\ny/n"); println!("Are you sure? Unsaved data will be lost.\ny/n");
io::stdin()
.read_line(&mut input_confirmation)
.expect("Couldn't read form stdin");
match io::stdin().read_line(&mut input_confirmation) {
Ok(_) => {}
Err(e) => {
return Err(ShellError::ExecuteFailure(format!(
"Couldn't read from stdin. {e}",
)));
}
}
if input_confirmation.starts_with('y') { if input_confirmation.starts_with('y') {
match logout() { match logout() {
Ok(_) => println!("Logging out"), Ok(_) => println!("Logging out"),

Loading…
Cancel
Save