mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-08-01 13:37:48 +00:00
clippy: remove some unnecessary mut
removing useless mutability mostly.
This commit is contained in:
parent
7a26f94399
commit
7679e90818
5 changed files with 10 additions and 9 deletions
|
@ -21,7 +21,7 @@ const BUF_SIZE: usize = 1024 * 16;
|
|||
/// copying or not. False means we don't have to.
|
||||
#[inline]
|
||||
pub(super) fn write_fast_using_splice<R: FdReadable>(
|
||||
handle: &mut InputHandle<R>,
|
||||
handle: &InputHandle<R>,
|
||||
write_fd: &impl AsRawFd,
|
||||
) -> CatResult<bool> {
|
||||
let (pipe_rd, pipe_wr) = pipe()?;
|
||||
|
|
|
@ -207,8 +207,7 @@ fn digest_read<T: Read>(
|
|||
Ok((digest.result_str(), output_size))
|
||||
} else {
|
||||
// Assume it's SHAKE. result_str() doesn't work with shake (as of 8/30/2016)
|
||||
let mut bytes = Vec::new();
|
||||
bytes.resize((output_bits + 7) / 8, 0);
|
||||
let mut bytes = vec![0; (output_bits + 7) / 8];
|
||||
digest.hash_finalize(&mut bytes);
|
||||
Ok((encode(bytes), output_size))
|
||||
}
|
||||
|
|
5
src/uu/env/src/env.rs
vendored
5
src/uu/env/src/env.rs
vendored
|
@ -101,7 +101,7 @@ fn load_config_file(opts: &mut Options) -> UResult<()> {
|
|||
|
||||
#[cfg(not(windows))]
|
||||
#[allow(clippy::ptr_arg)]
|
||||
fn build_command<'a, 'b>(args: &'a mut Vec<&'b str>) -> (Cow<'b, str>, &'a [&'b str]) {
|
||||
fn build_command<'a, 'b>(args: &'a Vec<&'b str>) -> (Cow<'b, str>, &'a [&'b str]) {
|
||||
let progname = Cow::from(args[0]);
|
||||
(progname, &args[1..])
|
||||
}
|
||||
|
@ -303,7 +303,10 @@ fn run_env(args: impl uucore::Args) -> UResult<()> {
|
|||
print_env(opts.line_ending);
|
||||
} else {
|
||||
// we need to execute a command
|
||||
#[cfg(windows)]
|
||||
let (prog, args) = build_command(&mut opts.program);
|
||||
#[cfg(not(windows))]
|
||||
let (prog, args) = build_command(&opts.program);
|
||||
|
||||
/*
|
||||
* On Unix-like systems Command::status either ends up calling either fork or posix_spawnp
|
||||
|
|
|
@ -803,8 +803,7 @@ fn digest_reader<T: Read>(
|
|||
Ok(digest.result_str())
|
||||
} else {
|
||||
// Assume it's SHAKE. result_str() doesn't work with shake (as of 8/30/2016)
|
||||
let mut bytes = Vec::new();
|
||||
bytes.resize((output_bits + 7) / 8, 0);
|
||||
let mut bytes = vec![0; (output_bits + 7) / 8];
|
||||
digest.hash_finalize(&mut bytes);
|
||||
Ok(encode(bytes))
|
||||
}
|
||||
|
|
|
@ -224,7 +224,7 @@ fn read_write_loop<I: WriteableTmpFile>(
|
|||
let mut sender_option = Some(sender);
|
||||
let mut tmp_files = vec![];
|
||||
loop {
|
||||
let mut chunk = match receiver.recv() {
|
||||
let chunk = match receiver.recv() {
|
||||
Ok(it) => it,
|
||||
_ => {
|
||||
return Ok(ReadResult::WroteChunksToFile { tmp_files });
|
||||
|
@ -232,7 +232,7 @@ fn read_write_loop<I: WriteableTmpFile>(
|
|||
};
|
||||
|
||||
let tmp_file = write::<I>(
|
||||
&mut chunk,
|
||||
&chunk,
|
||||
tmp_dir.next_file()?,
|
||||
settings.compress_prog.as_deref(),
|
||||
separator,
|
||||
|
@ -262,7 +262,7 @@ fn read_write_loop<I: WriteableTmpFile>(
|
|||
/// Write the lines in `chunk` to `file`, separated by `separator`.
|
||||
/// `compress_prog` is used to optionally compress file contents.
|
||||
fn write<I: WriteableTmpFile>(
|
||||
chunk: &mut Chunk,
|
||||
chunk: &Chunk,
|
||||
file: (File, PathBuf),
|
||||
compress_prog: Option<&str>,
|
||||
separator: u8,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue