Skip to content

Commit

Permalink
(feat on clippy-fix) Better syntax for clyppy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
TomPlanche committed Jan 26, 2025
1 parent 8f049ac commit befe03f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ impl App {
.game
.bot
.as_ref()
.map_or(false, |bot| bot.is_bot_starting)
.is_some_and(|bot| bot.is_bot_starting)
{
self.game.execute_bot_move();
self.game.player_turn = PieceColor::Black;
Expand Down
2 changes: 1 addition & 1 deletion src/game_logic/game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl Game {
self.game_state = GameState::Draw;
}

if (self.bot.is_none() || (self.bot.as_ref().map_or(false, |bot| bot.is_bot_starting)))
if (self.bot.is_none() || (self.bot.as_ref().is_some_and(|bot| bot.is_bot_starting)))
&& (self.opponent.is_none())
&& (!self.game_board.is_latest_move_promotion()
|| self.game_board.is_draw(self.player_turn)
Expand Down
4 changes: 2 additions & 2 deletions src/game_logic/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ impl UI {
if !game.game_board.move_history.is_empty() {
last_move = game.game_board.move_history.last();
if game.bot.is_some()
&& !game.bot.as_ref().map_or(false, |bot| bot.is_bot_starting)
&& !game.bot.as_ref().is_some_and(|bot| bot.is_bot_starting)
{
last_move_from = last_move.map(|m| m.from).unwrap();
last_move_to = last_move.map(|m| m.to).unwrap();
Expand Down Expand Up @@ -457,7 +457,7 @@ impl UI {
}
// Draw the cell green if this is the selected cell or if the cell is part of the last move
else if (i == self.selected_coordinates.row && j == self.selected_coordinates.col)
|| (last_move_from == Coord::new(i, j) // If the last move from
|| (last_move_from == Coord::new(i, j) // If the last move from
|| (last_move_to == Coord::new(i, j) // If last move to
&& !is_cell_in_positions(&positions, i, j)))
// and not in the authorized positions (grey instead of green)
Expand Down
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ fn main() -> AppResult<()> {
Event::Mouse(mouse_event) => handle_mouse_events(mouse_event, &mut app)?,
Event::Resize(_, _) => {}
}
if app.game.bot.is_some() && app.game.bot.as_ref().map_or(false, |bot| bot.bot_will_move) {
if app.game.bot.is_some() && app.game.bot.as_ref().is_some_and(|bot| bot.bot_will_move) {
app.game.execute_bot_move();
app.game.switch_player_turn();
if let Some(bot) = app.game.bot.as_mut() {
Expand All @@ -111,7 +111,7 @@ fn main() -> AppResult<()> {
.game
.opponent
.as_ref()
.map_or(false, |opponent| !opponent.game_started)
.is_some_and(|opponent| !opponent.game_started)
{
let opponent = app.game.opponent.as_mut().unwrap();
wait_for_game_start(opponent.stream.as_ref().unwrap());
Expand All @@ -125,7 +125,7 @@ fn main() -> AppResult<()> {
.game
.opponent
.as_ref()
.map_or(false, |opponent| opponent.opponent_will_move)
.is_some_and(|opponent| opponent.opponent_will_move)
{
tui.draw(&mut app)?;

Expand Down

0 comments on commit befe03f

Please sign in to comment.