From 43dc24718c442ef45f6cecf5790df0ab84a72cfc Mon Sep 17 00:00:00 2001 From: eug-vs Date: Thu, 23 Feb 2023 13:21:57 +0300 Subject: refactor: apply clippy suggestions --- src/grossmeister/move_generation.rs | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'src/grossmeister/move_generation.rs') diff --git a/src/grossmeister/move_generation.rs b/src/grossmeister/move_generation.rs index 25d92c7..c3acc91 100644 --- a/src/grossmeister/move_generation.rs +++ b/src/grossmeister/move_generation.rs @@ -153,7 +153,7 @@ impl Grossmeister { } } } - return moves + moves } /// Evaluate move for move ordering, prioritizing efficient captures @@ -195,25 +195,20 @@ impl Grossmeister { let mut ordered_moves: Vec = moves_with_eval.iter().map(|(m, _)| *m).collect(); // Insert killer moves after winning captures - let equal_capture_index = match moves_with_eval.iter().position(|(m, eval)| m.is_tactical() && *eval == 0.0) { - Some(x) => x, - None => 0, - }; + let equal_capture_index = moves_with_eval + .iter() + .position(|(m, eval)| m.is_tactical() && *eval == 0.0) + .unwrap_or(0); for killer in killer_moves { - match ordered_moves.iter().position(|m| *m == killer) { - Some(index) => { + if let Some(index) = ordered_moves.iter().position(|m| *m == killer) { let mov = ordered_moves.remove(index); ordered_moves.insert(equal_capture_index, mov); - } - None => {} - }; - + } } - match self.transposition() { - Some(transposition) => ordered_moves.insert(0, transposition.mov), - None => {}, + if let Some(transposition) = self.transposition() { + ordered_moves.insert(0, transposition.mov); } ordered_moves -- cgit v1.2.3