cleanup: move default() functions to impl Default

As suggested by a newer version of Clippy.
This commit is contained in:
Martin von Zweigbergk 2022-10-09 11:56:30 -07:00 committed by Martin von Zweigbergk
parent e11540162a
commit 6526b76ef0
2 changed files with 16 additions and 12 deletions

View File

@ -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
}

View File

@ -315,14 +315,8 @@ pub struct BackendFactories {
factories: HashMap<String, BackendFactory>,
}
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);