From b929cb85251c3fdb9c71f65ad2946c714dffa57d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20R=C3=BC=C3=9Fler?= Date: Mon, 8 Sep 2025 11:26:41 +0200 Subject: [PATCH] Derive Default per clippy recommendation --- asyncgit/src/sync/config.rs | 18 ++++-------------- asyncgit/src/sync/diff.rs | 9 ++------- asyncgit/src/sync/remotes/push.rs | 9 ++------- asyncgit/src/sync/status.rs | 9 ++------- 4 files changed, 10 insertions(+), 35 deletions(-) diff --git a/asyncgit/src/sync/config.rs b/asyncgit/src/sync/config.rs index f15e9cf937..cc3761c934 100644 --- a/asyncgit/src/sync/config.rs +++ b/asyncgit/src/sync/config.rs @@ -8,10 +8,11 @@ use super::{repository::repo, RepoPath}; // see https://git-scm.com/docs/git-config#Documentation/git-config.txt-statusshowUntrackedFiles /// represents the `status.showUntrackedFiles` git config state #[derive( - Hash, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, + Hash, Copy, Clone, Default, PartialEq, Eq, Serialize, Deserialize, )] pub enum ShowUntrackedFilesConfig { /// + #[default] No, /// Normal, @@ -19,12 +20,6 @@ pub enum ShowUntrackedFilesConfig { All, } -impl Default for ShowUntrackedFilesConfig { - fn default() -> Self { - Self::No - } -} - impl ShowUntrackedFilesConfig { /// pub const fn include_none(self) -> bool { @@ -68,21 +63,16 @@ pub fn untracked_files_config_repo( // see https://git-scm.com/docs/git-config#Documentation/git-config.txt-pushdefault /// represents `push.default` git config -#[derive(PartialEq, Eq)] +#[derive(PartialEq, Default, Eq)] pub enum PushDefaultStrategyConfig { Nothing, Current, Upstream, + #[default] Simple, Matching, } -impl Default for PushDefaultStrategyConfig { - fn default() -> Self { - Self::Simple - } -} - impl<'a> TryFrom<&'a str> for PushDefaultStrategyConfig { type Error = crate::Error; fn try_from( diff --git a/asyncgit/src/sync/diff.rs b/asyncgit/src/sync/diff.rs index d02a00a121..c13fc476c7 100644 --- a/asyncgit/src/sync/diff.rs +++ b/asyncgit/src/sync/diff.rs @@ -22,9 +22,10 @@ use serde::{Deserialize, Serialize}; use std::{cell::RefCell, fs, path::Path, rc::Rc}; /// type of diff of a single line -#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] +#[derive(Copy, Clone, Default, PartialEq, Eq, Hash, Debug)] pub enum DiffLineType { /// just surrounding line, no change + #[default] None, /// header of the hunk Header, @@ -47,12 +48,6 @@ impl From for DiffLineType { } } -impl Default for DiffLineType { - fn default() -> Self { - Self::None - } -} - /// #[derive(Default, Clone, Hash, Debug)] pub struct DiffLine { diff --git a/asyncgit/src/sync/remotes/push.rs b/asyncgit/src/sync/remotes/push.rs index 0916bfdc91..a4146a8461 100644 --- a/asyncgit/src/sync/remotes/push.rs +++ b/asyncgit/src/sync/remotes/push.rs @@ -98,20 +98,15 @@ impl AsyncProgress for ProgressNotification { } /// -#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)] pub enum PushType { /// + #[default] Branch, /// Tag, } -impl Default for PushType { - fn default() -> Self { - Self::Branch - } -} - #[cfg(test)] pub fn push_branch( repo_path: &RepoPath, diff --git a/asyncgit/src/sync/status.rs b/asyncgit/src/sync/status.rs index f0116fd106..b86155f094 100644 --- a/asyncgit/src/sync/status.rs +++ b/asyncgit/src/sync/status.rs @@ -104,9 +104,10 @@ pub struct StatusItem { } /// -#[derive(Copy, Clone, Hash, PartialEq, Eq, Debug)] +#[derive(Copy, Clone, Default, Hash, PartialEq, Eq, Debug)] pub enum StatusType { /// + #[default] WorkingDir, /// Stage, @@ -114,12 +115,6 @@ pub enum StatusType { Both, } -impl Default for StatusType { - fn default() -> Self { - Self::WorkingDir - } -} - impl From for StatusShow { fn from(s: StatusType) -> Self { match s {