@@ -110,15 +110,16 @@ impl UError for Error {
110110pub type CopyResult < T > = Result < T , Error > ;
111111
112112/// Specifies how to overwrite files.
113- #[ derive( Clone , Copy , Eq , PartialEq ) ]
113+ #[ derive( Debug , Clone , Copy , Eq , PartialEq , Default ) ]
114114pub enum ClobberMode {
115115 Force ,
116116 RemoveDestination ,
117+ #[ default]
117118 Standard ,
118119}
119120
120121/// Specifies whether files should be overwritten.
121- #[ derive( Clone , Copy , Eq , PartialEq ) ]
122+ #[ derive( Debug , Clone , Copy , Eq , PartialEq ) ]
122123pub enum OverwriteMode {
123124 /// [Default] Always overwrite existing files
124125 Clobber ( ClobberMode ) ,
@@ -128,18 +129,39 @@ pub enum OverwriteMode {
128129 NoClobber ,
129130}
130131
132+ impl Default for OverwriteMode {
133+ fn default ( ) -> Self {
134+ Self :: Clobber ( ClobberMode :: default ( ) )
135+ }
136+ }
137+
131138/// Possible arguments for `--reflink`.
132- #[ derive( Copy , Clone , Eq , PartialEq ) ]
139+ #[ derive( Debug , Copy , Clone , Eq , PartialEq ) ]
133140pub enum ReflinkMode {
134141 Always ,
135142 Auto ,
136143 Never ,
137144}
138145
146+ impl Default for ReflinkMode {
147+ #[ allow( clippy:: derivable_impls) ]
148+ fn default ( ) -> Self {
149+ #[ cfg( any( target_os = "linux" , target_os = "android" , target_os = "macos" ) ) ]
150+ {
151+ ReflinkMode :: Auto
152+ }
153+ #[ cfg( not( any( target_os = "linux" , target_os = "android" , target_os = "macos" ) ) ) ]
154+ {
155+ ReflinkMode :: Never
156+ }
157+ }
158+ }
159+
139160/// Possible arguments for `--sparse`.
140- #[ derive( Copy , Clone , Eq , PartialEq ) ]
161+ #[ derive( Debug , Copy , Clone , Eq , PartialEq , Default ) ]
141162pub enum SparseMode {
142163 Always ,
164+ #[ default]
143165 Auto ,
144166 Never ,
145167}
@@ -152,10 +174,11 @@ pub enum TargetType {
152174}
153175
154176/// Copy action to perform
155- #[ derive( PartialEq ) ]
177+ #[ derive( Debug , Clone , Eq , PartialEq , Default ) ]
156178pub enum CopyMode {
157179 Link ,
158180 SymLink ,
181+ #[ default]
159182 Copy ,
160183 Update ,
161184 AttrOnly ,
@@ -174,7 +197,7 @@ pub enum CopyMode {
174197/// For full compatibility with GNU, these options should also combine. We
175198/// currently only do a best effort imitation of that behavior, because it is
176199/// difficult to achieve in clap, especially with `--no-preserve`.
177- #[ derive( Debug , PartialEq , Clone , Copy ) ]
200+ #[ derive( Debug , PartialEq , Eq , Clone , Copy ) ]
178201pub struct Attributes {
179202 #[ cfg( unix) ]
180203 pub ownership : Preserve ,
@@ -185,6 +208,12 @@ pub struct Attributes {
185208 pub xattr : Preserve ,
186209}
187210
211+ impl Default for Attributes {
212+ fn default ( ) -> Self {
213+ Self :: NONE
214+ }
215+ }
216+
188217#[ derive( Clone , Copy , Debug , PartialEq , Eq ) ]
189218pub enum Preserve {
190219 // explicit means whether the --no-preserve flag is used or not to distinguish out the default value.
@@ -224,6 +253,7 @@ impl Ord for Preserve {
224253///
225254/// The fields are documented with the arguments that determine their value.
226255#[ allow( dead_code) ]
256+ #[ derive( Debug , Clone , Eq , PartialEq ) ]
227257pub struct Options {
228258 /// `--attributes-only`
229259 pub attributes_only : bool ,
@@ -287,6 +317,34 @@ pub struct Options {
287317 pub progress_bar : bool ,
288318}
289319
320+ impl Default for Options {
321+ fn default ( ) -> Self {
322+ Self {
323+ attributes_only : false ,
324+ backup : BackupMode :: default ( ) ,
325+ copy_contents : false ,
326+ cli_dereference : false ,
327+ copy_mode : CopyMode :: default ( ) ,
328+ dereference : false ,
329+ no_target_dir : false ,
330+ one_file_system : false ,
331+ overwrite : OverwriteMode :: default ( ) ,
332+ parents : false ,
333+ sparse_mode : SparseMode :: default ( ) ,
334+ strip_trailing_slashes : false ,
335+ reflink_mode : ReflinkMode :: default ( ) ,
336+ attributes : Attributes :: default ( ) ,
337+ recursive : false ,
338+ backup_suffix : backup_control:: DEFAULT_BACKUP_SUFFIX . to_owned ( ) ,
339+ target_dir : None ,
340+ update : UpdateMode :: default ( ) ,
341+ debug : false ,
342+ verbose : false ,
343+ progress_bar : false ,
344+ }
345+ }
346+ }
347+
290348/// Enum representing if a file has been skipped.
291349#[ derive( Clone , Copy , Debug , PartialEq , Eq ) ]
292350enum PerformedAction {
@@ -1091,18 +1149,7 @@ impl Options {
10911149 }
10921150 }
10931151 } else {
1094- #[ cfg( any( target_os = "linux" , target_os = "android" , target_os = "macos" ) ) ]
1095- {
1096- ReflinkMode :: Auto
1097- }
1098- #[ cfg( not( any(
1099- target_os = "linux" ,
1100- target_os = "android" ,
1101- target_os = "macos"
1102- ) ) ) ]
1103- {
1104- ReflinkMode :: Never
1105- }
1152+ ReflinkMode :: default ( )
11061153 }
11071154 } ,
11081155 sparse_mode : {
0 commit comments