From a4fe32973fd149dd0bab84b0a9cc25e2d798229d Mon Sep 17 00:00:00 2001 From: iGxnon Date: Tue, 9 Jan 2024 10:13:39 +0800 Subject: [PATCH] chore: code smell Signed-off-by: iGxnon --- curp/src/client/mod.rs | 6 ++---- xline/src/storage/compact/periodic_compactor.rs | 3 +-- xline/src/storage/compact/revision_compactor.rs | 3 +-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/curp/src/client/mod.rs b/curp/src/client/mod.rs index 30ee04ab8..fe2505c78 100644 --- a/curp/src/client/mod.rs +++ b/curp/src/client/mod.rs @@ -144,7 +144,7 @@ trait LeaderStateUpdate { } /// Client builder to build a client -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Default)] #[allow(clippy::module_name_repetitions)] // better than just Builder pub struct ClientBuilder { /// initial cluster version @@ -175,10 +175,8 @@ impl ClientBuilder { #[must_use] pub fn new(config: ClientConfig) -> Self { Self { - cluster_version: None, - all_members: None, - leader_state: None, config, + ..ClientBuilder::default() } } diff --git a/xline/src/storage/compact/periodic_compactor.rs b/xline/src/storage/compact/periodic_compactor.rs index 453f4770d..4f8e62bb9 100644 --- a/xline/src/storage/compact/periodic_compactor.rs +++ b/xline/src/storage/compact/periodic_compactor.rs @@ -87,7 +87,6 @@ impl PeriodicCompactor { } /// perform auto compaction logic - #[allow(clippy::pattern_type_mismatch)] // allow let Some matching async fn do_compact( &self, last_revision: Option, @@ -108,7 +107,7 @@ impl PeriodicCompactor { revision, self.period ); - let Some(compactable) = &*self.compactable.read().await else { + let Some(ref compactable) = *self.compactable.read().await else { return None; }; diff --git a/xline/src/storage/compact/revision_compactor.rs b/xline/src/storage/compact/revision_compactor.rs index 08adc9f24..4518febfa 100644 --- a/xline/src/storage/compact/revision_compactor.rs +++ b/xline/src/storage/compact/revision_compactor.rs @@ -50,7 +50,6 @@ impl RevisionCompactor { } /// perform auto compaction logic - #[allow(clippy::pattern_type_mismatch)] // allow let Some matching async fn do_compact(&self, last_revision: Option) -> Option { if !self.is_leader.load(Relaxed) { return None; @@ -67,7 +66,7 @@ impl RevisionCompactor { target_revision, self.retention ); - let Some(compactable) = &*self.compactable.read().await else { + let Some(ref compactable) = *self.compactable.read().await else { return None; };