Skip to content

Commit b52b9a5

Browse files
authored
Merge pull request #271 from fox0/clippy--needless_borrow
Fix clippy::needless_borrow
2 parents 21e42c6 + bcf7183 commit b52b9a5

File tree

6 files changed

+22
-22
lines changed

6 files changed

+22
-22
lines changed

sys/ps.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ fn main() {
148148

149149
// Print the header
150150
for field in &output_fields {
151-
let header = posix_fields.get(*field).unwrap_or(&field);
151+
let header = posix_fields.get(*field).unwrap_or(field);
152152
print!("{:<10} ", header);
153153
}
154154
println!();

text/diff_util/dir_data.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ impl DirData {
3939
}
4040

4141
pub fn path_str(&self) -> &str {
42-
&self.path.to_str().unwrap_or(COULD_NOT_UNWRAP_FILENAME)
42+
self.path.to_str().unwrap_or(COULD_NOT_UNWRAP_FILENAME)
4343
}
4444
}

text/diff_util/dir_diff.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl<'a> DirDiff<'a> {
3737
let mut dir1: DirData = DirData::load(path1)?;
3838
let mut dir2: DirData = DirData::load(path2)?;
3939

40-
let mut dir_diff = DirDiff::new(&mut dir1, &mut dir2, &format_options, recursive);
40+
let mut dir_diff = DirDiff::new(&mut dir1, &mut dir2, format_options, recursive);
4141
return dir_diff.analyze();
4242
}
4343

@@ -177,13 +177,13 @@ impl<'a> DirDiff<'a> {
177177
} else {
178178
let (file, dir) = if in_dir1_is_file && !in_dir2_is_file {
179179
(
180-
path1.to_str().unwrap_or(&COULD_NOT_UNWRAP_FILENAME),
181-
path2.to_str().unwrap_or(&COULD_NOT_UNWRAP_FILENAME),
180+
path1.to_str().unwrap_or(COULD_NOT_UNWRAP_FILENAME),
181+
path2.to_str().unwrap_or(COULD_NOT_UNWRAP_FILENAME),
182182
)
183183
} else {
184184
(
185-
path2.to_str().unwrap_or(&COULD_NOT_UNWRAP_FILENAME),
186-
path1.to_str().unwrap_or(&COULD_NOT_UNWRAP_FILENAME),
185+
path2.to_str().unwrap_or(COULD_NOT_UNWRAP_FILENAME),
186+
path1.to_str().unwrap_or(COULD_NOT_UNWRAP_FILENAME),
187187
)
188188
};
189189

text/diff_util/file_data.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,6 @@ impl FileData {
109109
}
110110

111111
pub fn path(&self) -> &str {
112-
self.path.to_str().unwrap_or(&COULD_NOT_UNWRAP_FILENAME)
112+
self.path.to_str().unwrap_or(COULD_NOT_UNWRAP_FILENAME)
113113
}
114114
}

text/diff_util/file_diff.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl<'a> FileDiff<'a> {
8888

8989
if path1_file_type.is_file() {
9090
let path1_file = path1.clone();
91-
let path1_file = path1_file.file_name().expect(&COULD_NOT_UNWRAP_FILENAME);
91+
let path1_file = path1_file.file_name().expect(COULD_NOT_UNWRAP_FILENAME);
9292
let path2 = path2.join(path1_file);
9393

9494
if !check_existance(&path2)? {
@@ -98,7 +98,7 @@ impl<'a> FileDiff<'a> {
9898
return FileDiff::file_diff(path1, path2, format_options, None);
9999
} else {
100100
let path2_file = path2.clone();
101-
let path2_file = path2_file.file_name().expect(&COULD_NOT_UNWRAP_FILENAME);
101+
let path2_file = path2_file.file_name().expect(COULD_NOT_UNWRAP_FILENAME);
102102
let path1 = path1.join(path2_file);
103103

104104
if !check_existance(&path1)? {
@@ -151,22 +151,22 @@ impl<'a> FileDiff<'a> {
151151
for hunk_index in 0..hunks_count {
152152
let hunk = self.hunks.hunk_at_mut(hunk_index);
153153
match self.format_options.output_format {
154-
OutputFormat::Debug => hunk.print_debug(&self.file1, &self.file2),
154+
OutputFormat::Debug => hunk.print_debug(self.file1, self.file2),
155155
OutputFormat::Default => {
156-
hunk.print_default(&self.file1, &self.file2, hunk_index == hunks_count - 1)
156+
hunk.print_default(self.file1, self.file2, hunk_index == hunks_count - 1)
157157
}
158158
OutputFormat::EditScript => hunk.print_edit_script(
159-
&self.file1,
160-
&self.file2,
159+
self.file1,
160+
self.file2,
161161
hunk_index == hunks_count - 1,
162162
),
163163
OutputFormat::Context(_) => {
164164
eprintln!("OutputFormat::Context should be handled in other place");
165165
return Ok(DiffExitStatus::Trouble);
166166
}
167167
OutputFormat::ForwardEditScript => hunk.print_forward_edit_script(
168-
&self.file1,
169-
&self.file2,
168+
self.file1,
169+
self.file2,
170170
hunk_index == hunks_count - 1,
171171
),
172172
OutputFormat::Unified(_) => {
@@ -209,7 +209,7 @@ impl<'a> FileDiff<'a> {
209209

210210
for i in 1..=n {
211211
for j in 1..=m {
212-
let cost = if self.compare_lines(&self.file1.line(i - 1), &self.file2.line(j - 1)) {
212+
let cost = if self.compare_lines(self.file1.line(i - 1), self.file2.line(j - 1)) {
213213
if !file1_considered_lines.contains(&i) && !file2_considered_lines.contains(&j)
214214
{
215215
file1_considered_lines.push(i);
@@ -242,7 +242,7 @@ impl<'a> FileDiff<'a> {
242242

243243
i -= 1
244244
} else {
245-
if !self.compare_lines(&self.file1.line(i - 1), &self.file2.line(j - 1)) {
245+
if !self.compare_lines(self.file1.line(i - 1), self.file2.line(j - 1)) {
246246
self.add_change(Change::Substitute(ChangeData::new(i, j)));
247247
}
248248

@@ -287,7 +287,7 @@ impl<'a> FileDiff<'a> {
287287
.hunks
288288
.hunks()
289289
.iter()
290-
.filter(|hunk| !Change::is_none(&hunk.kind()) && !Change::is_unchanged(&hunk.kind()))
290+
.filter(|hunk| !Change::is_none(hunk.kind()) && !Change::is_unchanged(hunk.kind()))
291291
.map(|hunk| {
292292
(
293293
hunk.ln1_start() as i64,

tree/ls.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,7 @@ fn process_single_dir(
11851185
target_path
11861186
};
11871187

1188-
let entry = Entry::new(target_path, file_name_raw, &metadata, config)
1188+
let entry = Entry::new(target_path, file_name_raw, metadata, config)
11891189
.map_err(|e| io::Error::other(format!("'{path_str}': {e}")))?;
11901190

11911191
let mut include_entry = false;
@@ -1246,7 +1246,7 @@ fn process_single_dir(
12461246
}
12471247
print_contents(
12481248
config,
1249-
&current_dir_ref,
1249+
current_dir_ref,
12501250
&mut entries,
12511251
&mut errors,
12521252
&exit_code,
@@ -1271,7 +1271,7 @@ fn process_single_dir(
12711271
if dir_parent != current_dir_ref.as_path() {
12721272
print_contents(
12731273
config,
1274-
&current_dir_ref,
1274+
current_dir_ref,
12751275
&mut entries,
12761276
&mut errors,
12771277
&exit_code,

0 commit comments

Comments
 (0)