From da6060cf3780cf753624debd47828c394847d9c6 Mon Sep 17 00:00:00 2001 From: Baptiste Fouques Date: Wed, 22 Feb 2023 11:19:30 +0100 Subject: [PATCH] remove unnecessary Result function return value --- chess_uci/src/lib.rs | 11 ++++------- chess_uci/src/uci_command.rs | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/chess_uci/src/lib.rs b/chess_uci/src/lib.rs index a6d3454..9b82147 100644 --- a/chess_uci/src/lib.rs +++ b/chess_uci/src/lib.rs @@ -346,9 +346,9 @@ impl UciEngine { } } - pub fn go(&mut self) -> Result<(), &'static str> { + pub fn go(&mut self) { match self.player[self.side_to_move().to_index()] { - Player::Human { .. } => Err("Not a machine to play for current color."), + Player::Human { .. } => warn!("Not a machine to play for current color."), Player::Engine { elo } => { if self.is_uciok() { if let Some(elo) = elo { @@ -367,17 +367,14 @@ impl UciEngine { btime, bincr, }); - - Ok(()) } else { - Err("UCI engine not ready") + warn!("UCI engine not ready") } } } } - pub fn stop(&mut self) -> Result<(), &'static str> { + pub fn stop(&mut self) { self.push(GuiCommand::Stop); - Ok(()) } } diff --git a/chess_uci/src/uci_command.rs b/chess_uci/src/uci_command.rs index a999bdd..68db0eb 100644 --- a/chess_uci/src/uci_command.rs +++ b/chess_uci/src/uci_command.rs @@ -142,7 +142,7 @@ pub fn parse(message: &mut str) -> Result { Some("bestmove") => match message_iter.collect::>().as_slice() { [] => Err("Empty bestmove command"), [chessmove] => Ok(EngineCommand::BestMove { - best_move: ChessMove::from_str(chessmove).expect("chessmove is invalid"), + best_move: ChessMove::from_str(chessmove).expect(&format!("chessmove {:?} is invalid", chessmove)), ponder: None, }), [_, "ponder"] => Err("Empty ponder in bestmove command"),