From 6526b76ef083be9a04162d7ce09e4206dc13b289 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sun, 9 Oct 2022 11:56:30 -0700 Subject: [PATCH] cleanup: move `default()` functions to `impl Default` As suggested by a newer version of Clippy. --- lib/src/op_store.rs | 10 ++++++---- lib/src/repo.rs | 18 ++++++++++-------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/lib/src/op_store.rs b/lib/src/op_store.rs index 80a9172b1..3d74c7f55 100644 --- a/lib/src/op_store.rs +++ b/lib/src/op_store.rs @@ -28,15 +28,17 @@ impl Debug for WorkspaceId { } } +impl Default for WorkspaceId { + fn default() -> Self { + Self("default".to_string()) + } +} + impl WorkspaceId { pub fn new(value: String) -> Self { Self(value) } - pub fn default() -> Self { - Self("default".to_string()) - } - pub fn as_str(&self) -> &str { &self.0 } diff --git a/lib/src/repo.rs b/lib/src/repo.rs index 51dab11d8..36b633919 100644 --- a/lib/src/repo.rs +++ b/lib/src/repo.rs @@ -315,14 +315,8 @@ pub struct BackendFactories { factories: HashMap, } -impl BackendFactories { - pub fn empty() -> Self { - BackendFactories { - factories: HashMap::new(), - } - } - - pub fn default() -> Self { +impl Default for BackendFactories { + fn default() -> Self { let mut factories = BackendFactories::empty(); factories.add_backend( "local", @@ -334,6 +328,14 @@ impl BackendFactories { ); factories } +} + +impl BackendFactories { + pub fn empty() -> Self { + BackendFactories { + factories: HashMap::new(), + } + } pub fn add_backend(&mut self, name: &str, factory: BackendFactory) { self.factories.insert(name.to_string(), factory);