From cc76ac0cb5718f5369d593e9d4791b3cb3b2c748 Mon Sep 17 00:00:00 2001 From: Ivan Folgueira Bande Date: Mon, 23 Dec 2024 23:59:24 +0100 Subject: [PATCH] clippy changes --- examples/tic-tac-toe-gui/src/main.rs | 16 ++++++++-------- examples/toy-chat/src/main.rs | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/examples/tic-tac-toe-gui/src/main.rs b/examples/tic-tac-toe-gui/src/main.rs index 954c060..8cbeb8d 100644 --- a/examples/tic-tac-toe-gui/src/main.rs +++ b/examples/tic-tac-toe-gui/src/main.rs @@ -115,7 +115,7 @@ impl TicTacToeApp { TicTacToeApp { game_state: self.game_state, - waku: waku, + waku, game_topic: self.game_topic, tx: self.tx, player_role: self.player_role, @@ -151,19 +151,19 @@ impl TicTacToeApp { if let Ok(mut game_state) = self.game_state.try_lock() { if let Some(my_role) = self.player_role { - if (*game_state).current_turn != my_role { + if game_state.current_turn != my_role { return; // skip click if not my turn } } - if (*game_state).board[row][col].is_none() && (*game_state).moves_left > 0 { - (*game_state).board[row][col] = Some((*game_state).current_turn); - (*game_state).moves_left -= 1; + if game_state.board[row][col].is_none() && game_state.moves_left > 0 { + game_state.board[row][col] = Some(game_state.current_turn); + game_state.moves_left -= 1; if let Some(winner) = self.check_winner(&game_state) { - (*game_state).current_turn = winner; + game_state.current_turn = winner; } else { - (*game_state).current_turn = match (*game_state).current_turn { + game_state.current_turn = match game_state.current_turn { Player::X => Player::O, Player::O => Player::X, }; @@ -245,7 +245,7 @@ impl eframe::App for TicTacToeApp { if ui.button("Play as O").clicked() { self.player_role = Some(Player::O); if let Ok(mut game_state) = self.game_state.try_lock() { - (*game_state).current_turn = Player::X; // player X should start + game_state.current_turn = Player::X; // player X should start } } diff --git a/examples/toy-chat/src/main.rs b/examples/toy-chat/src/main.rs index 5684cf7..01ca567 100644 --- a/examples/toy-chat/src/main.rs +++ b/examples/toy-chat/src/main.rs @@ -76,8 +76,8 @@ impl App { input: String::new(), input_mode: InputMode::Normal, messages: Arc::new(RwLock::new(Vec::new())), - nick: nick, - waku: waku, + nick, + waku, }) } @@ -127,7 +127,7 @@ impl App { nick: self.nick, input_mode: self.input_mode, messages: self.messages, - waku: waku, + waku, }) } } @@ -157,7 +157,7 @@ impl App { }) .collect(); - if messages.len() > 0 { + if !messages.is_empty() { *self.messages.write().unwrap() = messages; } }