@@ -9,7 +9,7 @@ use crate::{
99} ;
1010
1111/// Holds the given command line arguments except "--version" and "--help".
12- #[ derive( Debug , Default , Clone , Eq , PartialEq ) ]
12+ #[ derive( Debug , Clone , Eq , PartialEq ) ]
1313pub struct ParamsSdiff {
1414 /// Identifier
1515 pub util : DiffUtility ,
@@ -48,13 +48,13 @@ pub struct ParamsSdiff {
4848 /// -s, --suppress-common-lines do not output common lines
4949 pub suppress_common_lines : bool ,
5050 /// --tabsize=NUM tab stops at every NUM (default 8) print columns
51- pub tabsize : Option < usize > ,
51+ pub tabsize : usize ,
5252 /// -a, --text treat all files as text
5353 pub text : bool ,
5454 /// -v, --version output version information and exit
5555 pub version : bool ,
5656 /// -w, --width=NUM output at most NUM (default 130) print columns
57- pub width : Option < usize > ,
57+ pub width : usize ,
5858}
5959
6060impl ParamsSdiff {
@@ -147,7 +147,7 @@ impl ParamsSdiff {
147147 Ok ( w) => w,
148148 Err ( _) => return Err ( ParamsSdiffError :: InvalidNumber ( parsed_option. clone ( ) ) ) ,
149149 } ;
150- self . tabsize = Some ( t ) ;
150+ self . tabsize = t ;
151151
152152 Ok ( t)
153153 }
@@ -158,12 +158,42 @@ impl ParamsSdiff {
158158 Ok ( w) => w,
159159 Err ( _) => return Err ( ParamsSdiffError :: InvalidNumber ( parsed_option. clone ( ) ) ) ,
160160 } ;
161- self . width = Some ( w ) ;
161+ self . width = w ;
162162
163163 Ok ( w)
164164 }
165165}
166166
167+ impl Default for ParamsSdiff {
168+ fn default ( ) -> Self {
169+ Self {
170+ util : DiffUtility :: SDiff ,
171+ from : Default :: default ( ) ,
172+ to : Default :: default ( ) ,
173+ diff_program : Default :: default ( ) ,
174+ expand_tabs : Default :: default ( ) ,
175+ help : Default :: default ( ) ,
176+ ignore_all_space : Default :: default ( ) ,
177+ ignore_blank_lines : Default :: default ( ) ,
178+ ignore_case : Default :: default ( ) ,
179+ ignore_matching_lines : Default :: default ( ) ,
180+ ignore_space_change : Default :: default ( ) ,
181+ ignore_tab_expansion : Default :: default ( ) ,
182+ ignore_trailing_space : Default :: default ( ) ,
183+ left_column : Default :: default ( ) ,
184+ minimal : Default :: default ( ) ,
185+ output : Default :: default ( ) ,
186+ speed_large_files : Default :: default ( ) ,
187+ strip_trailing_cr : Default :: default ( ) ,
188+ suppress_common_lines : Default :: default ( ) ,
189+ tabsize : 8 ,
190+ text : Default :: default ( ) ,
191+ version : Default :: default ( ) ,
192+ width : 130 ,
193+ }
194+ }
195+ }
196+
167197// Usually assert is used like assert_eq(test result, expected result).
168198#[ cfg( test) ]
169199mod tests {
@@ -269,10 +299,10 @@ mod tests {
269299 speed_large_files : true ,
270300 strip_trailing_cr : true ,
271301 suppress_common_lines : true ,
272- tabsize : Some ( 2 ) ,
302+ tabsize : 2 ,
273303 text : true ,
274304 version : false ,
275- width : Some ( 150 ) ,
305+ width : 150 ,
276306 } ;
277307 assert_eq ! (
278308 parse(
0 commit comments