Skip to content

Commit

Permalink
fix clippy warning: Fix the needless_pass_by_value
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvestre committed Feb 5, 2022
1 parent 59be8d5 commit f399291
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
8 changes: 4 additions & 4 deletions src/find/matchers/name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ mod tests {
create_file_link();

let link_f = get_dir_entry_for("test_data/links", "link-f");
let matcher = NameMatcher::new(&"link?f", false).unwrap();
let matcher = NameMatcher::new("link?f", false).unwrap();
let deps = FakeDependencies::new();
assert!(matcher.matches(&link_f, &mut deps.new_matcher_io()));
}
Expand All @@ -195,7 +195,7 @@ mod tests {
create_file_link();

let link_f = get_dir_entry_for("test_data/links", "link-f");
let matcher = NameMatcher::new(&"ab?bc", true).unwrap();
let matcher = NameMatcher::new("ab?bc", true).unwrap();
let deps = FakeDependencies::new();
assert!(matcher.matches(&link_f, &mut deps.new_matcher_io()));
}
Expand Down Expand Up @@ -235,7 +235,7 @@ mod tests {
create_file_link();

let link_f = get_dir_entry_for("test_data/links", "link-f");
let matcher = CaselessNameMatcher::new(&"linK?f", false).unwrap();
let matcher = CaselessNameMatcher::new("linK?f", false).unwrap();
let deps = FakeDependencies::new();
assert!(matcher.matches(&link_f, &mut deps.new_matcher_io()));
}
Expand All @@ -245,7 +245,7 @@ mod tests {
create_file_link();

let link_f = get_dir_entry_for("test_data/links", "link-f");
let matcher = CaselessNameMatcher::new(&"AbB?c", true).unwrap();
let matcher = CaselessNameMatcher::new("AbB?c", true).unwrap();
let deps = FakeDependencies::new();
assert!(matcher.matches(&link_f, &mut deps.new_matcher_io()));
}
Expand Down
8 changes: 4 additions & 4 deletions src/find/matchers/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ mod tests {
let new_file_name = "newFile";
File::create(temp_dir.path().join(new_file_name)).expect("create temp file");

let new_file = get_dir_entry_for(&temp_dir_path, &new_file_name);
let new_file = get_dir_entry_for(&temp_dir_path, new_file_name);

let matcher_for_new =
NewerMatcher::new(&temp_dir.path().join(new_file_name).to_string_lossy()).unwrap();
Expand Down Expand Up @@ -266,7 +266,7 @@ mod tests {

// set "now" to a second before the file was modified (e.g. the file was
// modified after find started running
deps.set_time(files_mtime - Duration::new(1 as u64, 0));
deps.set_time(files_mtime - Duration::new(1_u64, 0));
assert!(
!exactly_one_day_matcher.matches(&file, &mut deps.new_matcher_io()),
"future-modified file shouldn'1 match exactly 1 day old"
Expand Down Expand Up @@ -359,14 +359,14 @@ mod tests {
let mut deps = FakeDependencies::new();
deps.set_time(file_time);
assert!(
matcher.matches(&file_info, &mut deps.new_matcher_io()),
matcher.matches(file_info, &mut deps.new_matcher_io()),
"{:?} time matcher should match",
file_time_type
);

deps.set_time(file_time - Duration::from_secs(1));
assert!(
!matcher.matches(&file_info, &mut deps.new_matcher_io()),
!matcher.matches(file_info, &mut deps.new_matcher_io()),
"{:?} time matcher shouldn't match a second before",
file_time_type
);
Expand Down
2 changes: 1 addition & 1 deletion src/find/matchers/type_matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ mod tests {
let dir = get_dir_entry_for("test_data", "simple");
let deps = FakeDependencies::new();

for typ in ["b", "c", "p", "s"].iter() {
for typ in &["b", "c", "p", "s"] {
let matcher = TypeMatcher::new(&typ.to_string()).unwrap();
assert!(!matcher.matches(&dir, &mut deps.new_matcher_io()));
assert!(!matcher.matches(&file, &mut deps.new_matcher_io()));
Expand Down
14 changes: 6 additions & 8 deletions tests/exec_unit_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn matching_executes_code() {
let abbbc = get_dir_entry_for("test_data/simple", "abbbc");
let matcher = SingleExecMatcher::new(
&path_to_testing_commandline(),
&vec![temp_dir_path.as_ref(), "abc", "{}", "xyz"],
&[temp_dir_path.as_ref(), "abc", "{}", "xyz"],
false,
)
.expect("Failed to create matcher");
Expand Down Expand Up @@ -65,7 +65,7 @@ fn matching_executes_code_in_files_directory() {
let abbbc = get_dir_entry_for("test_data/simple", "abbbc");
let matcher = SingleExecMatcher::new(
&path_to_testing_commandline(),
&vec![temp_dir_path.as_ref(), "abc", "{}", "xyz"],
&[temp_dir_path.as_ref(), "abc", "{}", "xyz"],
true,
)
.expect("Failed to create matcher");
Expand Down Expand Up @@ -102,7 +102,7 @@ fn execdir_in_current_directory() {
.expect("result wasn't OK");
let matcher = SingleExecMatcher::new(
&path_to_testing_commandline(),
&vec![temp_dir_path.as_ref(), "abc", "{}", "xyz"],
&[temp_dir_path.as_ref(), "abc", "{}", "xyz"],
true,
)
.expect("Failed to create matcher");
Expand Down Expand Up @@ -144,7 +144,7 @@ fn execdir_in_root_directory() {

let matcher = SingleExecMatcher::new(
&path_to_testing_commandline(),
&vec![temp_dir_path.as_ref(), "abc", "{}", "xyz"],
&[temp_dir_path.as_ref(), "abc", "{}", "xyz"],
true,
)
.expect("Failed to create matcher");
Expand Down Expand Up @@ -176,13 +176,11 @@ fn matching_fails_if_executable_fails() {
let abbbc = get_dir_entry_for("test_data/simple", "abbbc");
let matcher = SingleExecMatcher::new(
&path_to_testing_commandline(),
&vec![
temp_dir_path.as_ref(),
&[temp_dir_path.as_ref(),
"--exit_with_failure",
"abc",
"{}",
"xyz",
],
"xyz"],
true,
)
.expect("Failed to create matcher");
Expand Down

0 comments on commit f399291

Please sign in to comment.