From 5122c3c06a43dc22dd52146dfaa65730ce9ebb15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E8=88=AA=E5=AE=87?= <3364451258@qq.com> Date: Sun, 31 May 2026 15:52:18 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20clippy=20warnings=20=E2=80=94=20too=5Fma?= =?UTF-8?q?ny=5Farguments=20+=20Default=20impls=20+=20needless=5Fborrows?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.7 --- core/src/ai/killer.rs | 10 ++++++++-- core/src/ai/opening.rs | 10 ++++++++-- core/src/ai/search.rs | 2 ++ core/src/types.rs | 2 +- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/core/src/ai/killer.rs b/core/src/ai/killer.rs index d8afe6e..207bf41 100644 --- a/core/src/ai/killer.rs +++ b/core/src/ai/killer.rs @@ -7,12 +7,18 @@ pub struct KillerTable { moves: [[Option; SLOTS_PER_DEPTH]; MAX_DEPTH], } -impl KillerTable { - pub fn new() -> Self { +impl Default for KillerTable { + fn default() -> Self { Self { moves: [[None; SLOTS_PER_DEPTH]; MAX_DEPTH], } } +} + +impl KillerTable { + pub fn new() -> Self { + Self::default() + } /// 记录产生剪枝的走法,同一位置不会重复存储 pub fn record(&mut self, depth: usize, pos: Position) { diff --git a/core/src/ai/opening.rs b/core/src/ai/opening.rs index 3a9a5e6..1a4177a 100644 --- a/core/src/ai/opening.rs +++ b/core/src/ai/opening.rs @@ -6,14 +6,20 @@ pub struct OpeningBook { positions: HashMap>, } -impl OpeningBook { - pub fn new() -> Self { +impl Default for OpeningBook { + fn default() -> Self { let mut book = Self { positions: HashMap::new(), }; book.load(); book } +} + +impl OpeningBook { + pub fn new() -> Self { + Self::default() + } fn load(&mut self) { let openings: Vec> = vec![ diff --git a/core/src/ai/search.rs b/core/src/ai/search.rs index f229486..462747e 100644 --- a/core/src/ai/search.rs +++ b/core/src/ai/search.rs @@ -79,6 +79,7 @@ impl AiEngine for AlphaBetaAi { } impl AlphaBetaAi { + #[allow(clippy::too_many_arguments)] fn search_depth( &self, board: &Board, @@ -162,6 +163,7 @@ impl AlphaBetaAi { (best_pos, completed) } + #[allow(clippy::too_many_arguments)] fn negamax( &self, board: &Board, diff --git a/core/src/types.rs b/core/src/types.rs index 5c65f9b..2901c87 100644 --- a/core/src/types.rs +++ b/core/src/types.rs @@ -169,7 +169,7 @@ pub fn init_zobrist_table(_board_size: usize) -> &'static Vec