Skip to content

Commit 4bd26a6

Browse files
committed
Clean up and simplify normalize_options
1 parent 3e005e7 commit 4bd26a6

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/xargs/mod.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ fn validate_positive_usize(s: &str) -> Result<usize, String> {
812812
}
813813
}
814814

815-
fn normalize_options<'a>(options: &'a Options, matches: &'a clap::ArgMatches) -> Options {
815+
fn normalize_options(options: Options, matches: &clap::ArgMatches) -> Options {
816816
let (max_args, max_lines, replace) =
817817
match (options.max_args, options.max_lines, &options.replace) {
818818
// These 3 options are mutually exclusive.
@@ -821,7 +821,7 @@ fn normalize_options<'a>(options: &'a Options, matches: &'a clap::ArgMatches) ->
821821
// If `replace`, all matches in initial args should be replaced with extra args read from stdin.
822822
// It is possible to have multiple matches and multiple extra args, and the Cartesian product is desired.
823823
// To be specific, we process extra args one by one, and replace all matches with the same extra arg in each time.
824-
(Some(1), None, options.replace.clone())
824+
(Some(1), None, options.replace)
825825
}
826826
(Some(_), None, None) | (None, Some(_), None) | (None, None, None) => {
827827
(options.max_args, options.max_lines, None)
@@ -846,7 +846,7 @@ fn normalize_options<'a>(options: &'a Options, matches: &'a clap::ArgMatches) ->
846846
} else if args_index > lines_index && args_index > replace_index {
847847
(options.max_args, None, None)
848848
} else {
849-
(Some(1), None, options.replace.clone())
849+
(Some(1), None, options.replace)
850850
}
851851
}
852852
};
@@ -871,11 +871,11 @@ fn normalize_options<'a>(options: &'a Options, matches: &'a clap::ArgMatches) ->
871871
let eof_delimiter = if delimiter.is_some() {
872872
None
873873
} else {
874-
options.eof_delimiter.clone()
874+
options.eof_delimiter
875875
};
876876

877877
Options {
878-
arg_file: options.arg_file.clone(),
878+
arg_file: options.arg_file,
879879
delimiter,
880880
exit_if_pass_char_limit: options.exit_if_pass_char_limit,
881881
max_args,
@@ -887,7 +887,6 @@ fn normalize_options<'a>(options: &'a Options, matches: &'a clap::ArgMatches) ->
887887
verbose: options.verbose,
888888
eof_delimiter,
889889
}
890-
// (max_args, max_lines, replace, delimiter, eof_delimiter)
891890
}
892891

893892
fn do_xargs(args: &[&str]) -> Result<CommandResult, XargsError> {
@@ -1090,7 +1089,7 @@ fn do_xargs(args: &[&str]) -> Result<CommandResult, XargsError> {
10901089
}),
10911090
};
10921091

1093-
let options = normalize_options(&options, &matches);
1092+
let options = normalize_options(options, &matches);
10941093

10951094
let action = match matches.get_many::<OsString>(options::COMMAND) {
10961095
Some(args) if args.len() > 0 => {

0 commit comments

Comments
 (0)