Skip to content

Commit 9f79492

Browse files
committed
uu clippy fix proposal.
removing useless mutability mostly.
1 parent 7a26f94 commit 9f79492

File tree

5 files changed

+10
-9
lines changed

5 files changed

+10
-9
lines changed

src/uu/cat/src/splice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const BUF_SIZE: usize = 1024 * 16;
2121
/// copying or not. False means we don't have to.
2222
#[inline]
2323
pub(super) fn write_fast_using_splice<R: FdReadable>(
24-
handle: &mut InputHandle<R>,
24+
handle: &InputHandle<R>,
2525
write_fd: &impl AsRawFd,
2626
) -> CatResult<bool> {
2727
let (pipe_rd, pipe_wr) = pipe()?;

src/uu/cksum/src/cksum.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,7 @@ fn digest_read<T: Read>(
207207
Ok((digest.result_str(), output_size))
208208
} else {
209209
// Assume it's SHAKE. result_str() doesn't work with shake (as of 8/30/2016)
210-
let mut bytes = Vec::new();
211-
bytes.resize((output_bits + 7) / 8, 0);
210+
let mut bytes = vec![0; (output_bits + 7) / 8];
212211
digest.hash_finalize(&mut bytes);
213212
Ok((encode(bytes), output_size))
214213
}

src/uu/env/src/env.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ fn load_config_file(opts: &mut Options) -> UResult<()> {
101101

102102
#[cfg(not(windows))]
103103
#[allow(clippy::ptr_arg)]
104-
fn build_command<'a, 'b>(args: &'a mut Vec<&'b str>) -> (Cow<'b, str>, &'a [&'b str]) {
104+
fn build_command<'a, 'b>(args: &'a Vec<&'b str>) -> (Cow<'b, str>, &'a [&'b str]) {
105105
let progname = Cow::from(args[0]);
106106
(progname, &args[1..])
107107
}
@@ -303,7 +303,10 @@ fn run_env(args: impl uucore::Args) -> UResult<()> {
303303
print_env(opts.line_ending);
304304
} else {
305305
// we need to execute a command
306+
#[cfg(windows)]
306307
let (prog, args) = build_command(&mut opts.program);
308+
#[cfg(not(windows))]
309+
let (prog, args) = build_command(&opts.program);
307310

308311
/*
309312
* On Unix-like systems Command::status either ends up calling either fork or posix_spawnp

src/uu/hashsum/src/hashsum.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -803,8 +803,7 @@ fn digest_reader<T: Read>(
803803
Ok(digest.result_str())
804804
} else {
805805
// Assume it's SHAKE. result_str() doesn't work with shake (as of 8/30/2016)
806-
let mut bytes = Vec::new();
807-
bytes.resize((output_bits + 7) / 8, 0);
806+
let mut bytes = vec![0; (output_bits + 7) / 8];
808807
digest.hash_finalize(&mut bytes);
809808
Ok(encode(bytes))
810809
}

src/uu/sort/src/ext_sort.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,15 +224,15 @@ fn read_write_loop<I: WriteableTmpFile>(
224224
let mut sender_option = Some(sender);
225225
let mut tmp_files = vec![];
226226
loop {
227-
let mut chunk = match receiver.recv() {
227+
let chunk = match receiver.recv() {
228228
Ok(it) => it,
229229
_ => {
230230
return Ok(ReadResult::WroteChunksToFile { tmp_files });
231231
}
232232
};
233233

234234
let tmp_file = write::<I>(
235-
&mut chunk,
235+
&chunk,
236236
tmp_dir.next_file()?,
237237
settings.compress_prog.as_deref(),
238238
separator,
@@ -262,7 +262,7 @@ fn read_write_loop<I: WriteableTmpFile>(
262262
/// Write the lines in `chunk` to `file`, separated by `separator`.
263263
/// `compress_prog` is used to optionally compress file contents.
264264
fn write<I: WriteableTmpFile>(
265-
chunk: &mut Chunk,
265+
chunk: &Chunk,
266266
file: (File, PathBuf),
267267
compress_prog: Option<&str>,
268268
separator: u8,

0 commit comments

Comments
 (0)