Refactor some clippy-pedantic errors

This commit is contained in:
stefiosif
2024-09-06 20:30:57 +03:00
parent 6b9650a6f0
commit 2093d91dfa
12 changed files with 42 additions and 47 deletions

View File

@@ -39,8 +39,8 @@ pub enum Response {
Info(String),
}
fn write_response(handle_out: &mut impl Write, response: Response) -> Result<(), String> {
writeln!(handle_out, "{}", response).map_err(|e| e.to_string())?;
fn write_response(handle_out: &mut impl Write, response: &Response) -> Result<(), String> {
writeln!(handle_out, "{response}").map_err(|e| e.to_string())?;
handle_out.flush().map_err(|e| e.to_string())?;
Ok(())
}
@@ -52,8 +52,8 @@ impl fmt::Display for Response {
match self {
Self::UciOk => write!(f, "id name ippos\nid author stefiosif\nuciok"),
Self::ReadyOk => write!(f, "readyok"),
Self::BestMove(best_move) => write!(f, "bestmove {}", best_move),
Self::Info(info) => write!(f, "{}", info),
Self::BestMove(best_move) => write!(f, "bestmove {best_move}"),
Self::Info(info) => write!(f, "{info}"),
}
}
}
@@ -174,7 +174,7 @@ pub fn uci_loop<R: BufRead, W: Write>(input: R, mut output: W) -> Result<(), Str
Command::Quit => break,
};
write_response(&mut output, response)?;
write_response(&mut output, &response)?;
output.flush().map_err(|e| e.to_string())?;
}