Skip to content

Commit 60912c0

Browse files
authored
Derive Default per clippy recommendation (#2712)
1 parent 8bff603 commit 60912c0

File tree

4 files changed

+10
-35
lines changed

4 files changed

+10
-35
lines changed

asyncgit/src/sync/config.rs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,18 @@ use super::{repository::repo, RepoPath};
88
// see https://git-scm.com/docs/git-config#Documentation/git-config.txt-statusshowUntrackedFiles
99
/// represents the `status.showUntrackedFiles` git config state
1010
#[derive(
11-
Hash, Copy, Clone, PartialEq, Eq, Serialize, Deserialize,
11+
Hash, Copy, Clone, Default, PartialEq, Eq, Serialize, Deserialize,
1212
)]
1313
pub enum ShowUntrackedFilesConfig {
1414
///
15+
#[default]
1516
No,
1617
///
1718
Normal,
1819
///
1920
All,
2021
}
2122

22-
impl Default for ShowUntrackedFilesConfig {
23-
fn default() -> Self {
24-
Self::No
25-
}
26-
}
27-
2823
impl ShowUntrackedFilesConfig {
2924
///
3025
pub const fn include_none(self) -> bool {
@@ -68,21 +63,16 @@ pub fn untracked_files_config_repo(
6863

6964
// see https://git-scm.com/docs/git-config#Documentation/git-config.txt-pushdefault
7065
/// represents `push.default` git config
71-
#[derive(PartialEq, Eq)]
66+
#[derive(PartialEq, Default, Eq)]
7267
pub enum PushDefaultStrategyConfig {
7368
Nothing,
7469
Current,
7570
Upstream,
71+
#[default]
7672
Simple,
7773
Matching,
7874
}
7975

80-
impl Default for PushDefaultStrategyConfig {
81-
fn default() -> Self {
82-
Self::Simple
83-
}
84-
}
85-
8676
impl<'a> TryFrom<&'a str> for PushDefaultStrategyConfig {
8777
type Error = crate::Error;
8878
fn try_from(

asyncgit/src/sync/diff.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ use serde::{Deserialize, Serialize};
2222
use std::{cell::RefCell, fs, path::Path, rc::Rc};
2323

2424
/// type of diff of a single line
25-
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
25+
#[derive(Copy, Clone, Default, PartialEq, Eq, Hash, Debug)]
2626
pub enum DiffLineType {
2727
/// just surrounding line, no change
28+
#[default]
2829
None,
2930
/// header of the hunk
3031
Header,
@@ -47,12 +48,6 @@ impl From<git2::DiffLineType> for DiffLineType {
4748
}
4849
}
4950

50-
impl Default for DiffLineType {
51-
fn default() -> Self {
52-
Self::None
53-
}
54-
}
55-
5651
///
5752
#[derive(Default, Clone, Hash, Debug)]
5853
pub struct DiffLine {

asyncgit/src/sync/remotes/push.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,20 +98,15 @@ impl AsyncProgress for ProgressNotification {
9898
}
9999

100100
///
101-
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
101+
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
102102
pub enum PushType {
103103
///
104+
#[default]
104105
Branch,
105106
///
106107
Tag,
107108
}
108109

109-
impl Default for PushType {
110-
fn default() -> Self {
111-
Self::Branch
112-
}
113-
}
114-
115110
#[cfg(test)]
116111
pub fn push_branch(
117112
repo_path: &RepoPath,

asyncgit/src/sync/status.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,22 +104,17 @@ pub struct StatusItem {
104104
}
105105

106106
///
107-
#[derive(Copy, Clone, Hash, PartialEq, Eq, Debug)]
107+
#[derive(Copy, Clone, Default, Hash, PartialEq, Eq, Debug)]
108108
pub enum StatusType {
109109
///
110+
#[default]
110111
WorkingDir,
111112
///
112113
Stage,
113114
///
114115
Both,
115116
}
116117

117-
impl Default for StatusType {
118-
fn default() -> Self {
119-
Self::WorkingDir
120-
}
121-
}
122-
123118
impl From<StatusType> for StatusShow {
124119
fn from(s: StatusType) -> Self {
125120
match s {

0 commit comments

Comments
 (0)