mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-08-02 05:57:46 +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.
|
/// copying or not. False means we don't have to.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub(super) fn write_fast_using_splice<R: FdReadable>(
|
pub(super) fn write_fast_using_splice<R: FdReadable>(
|
||||||
handle: &mut InputHandle<R>,
|
handle: &InputHandle<R>,
|
||||||
write_fd: &impl AsRawFd,
|
write_fd: &impl AsRawFd,
|
||||||
) -> CatResult<bool> {
|
) -> CatResult<bool> {
|
||||||
let (pipe_rd, pipe_wr) = pipe()?;
|
let (pipe_rd, pipe_wr) = pipe()?;
|
||||||
|
|
|
@ -207,8 +207,7 @@ fn digest_read<T: Read>(
|
||||||
Ok((digest.result_str(), output_size))
|
Ok((digest.result_str(), output_size))
|
||||||
} else {
|
} else {
|
||||||
// Assume it's SHAKE. result_str() doesn't work with shake (as of 8/30/2016)
|
// Assume it's SHAKE. result_str() doesn't work with shake (as of 8/30/2016)
|
||||||
let mut bytes = Vec::new();
|
let mut bytes = vec![0; (output_bits + 7) / 8];
|
||||||
bytes.resize((output_bits + 7) / 8, 0);
|
|
||||||
digest.hash_finalize(&mut bytes);
|
digest.hash_finalize(&mut bytes);
|
||||||
Ok((encode(bytes), output_size))
|
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))]
|
#[cfg(not(windows))]
|
||||||
#[allow(clippy::ptr_arg)]
|
#[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]);
|
let progname = Cow::from(args[0]);
|
||||||
(progname, &args[1..])
|
(progname, &args[1..])
|
||||||
}
|
}
|
||||||
|
@ -303,7 +303,10 @@ fn run_env(args: impl uucore::Args) -> UResult<()> {
|
||||||
print_env(opts.line_ending);
|
print_env(opts.line_ending);
|
||||||
} else {
|
} else {
|
||||||
// we need to execute a command
|
// we need to execute a command
|
||||||
|
#[cfg(windows)]
|
||||||
let (prog, args) = build_command(&mut opts.program);
|
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
|
* 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())
|
Ok(digest.result_str())
|
||||||
} else {
|
} else {
|
||||||
// Assume it's SHAKE. result_str() doesn't work with shake (as of 8/30/2016)
|
// Assume it's SHAKE. result_str() doesn't work with shake (as of 8/30/2016)
|
||||||
let mut bytes = Vec::new();
|
let mut bytes = vec![0; (output_bits + 7) / 8];
|
||||||
bytes.resize((output_bits + 7) / 8, 0);
|
|
||||||
digest.hash_finalize(&mut bytes);
|
digest.hash_finalize(&mut bytes);
|
||||||
Ok(encode(bytes))
|
Ok(encode(bytes))
|
||||||
}
|
}
|
||||||
|
|
|
@ -224,7 +224,7 @@ fn read_write_loop<I: WriteableTmpFile>(
|
||||||
let mut sender_option = Some(sender);
|
let mut sender_option = Some(sender);
|
||||||
let mut tmp_files = vec![];
|
let mut tmp_files = vec![];
|
||||||
loop {
|
loop {
|
||||||
let mut chunk = match receiver.recv() {
|
let chunk = match receiver.recv() {
|
||||||
Ok(it) => it,
|
Ok(it) => it,
|
||||||
_ => {
|
_ => {
|
||||||
return Ok(ReadResult::WroteChunksToFile { tmp_files });
|
return Ok(ReadResult::WroteChunksToFile { tmp_files });
|
||||||
|
@ -232,7 +232,7 @@ fn read_write_loop<I: WriteableTmpFile>(
|
||||||
};
|
};
|
||||||
|
|
||||||
let tmp_file = write::<I>(
|
let tmp_file = write::<I>(
|
||||||
&mut chunk,
|
&chunk,
|
||||||
tmp_dir.next_file()?,
|
tmp_dir.next_file()?,
|
||||||
settings.compress_prog.as_deref(),
|
settings.compress_prog.as_deref(),
|
||||||
separator,
|
separator,
|
||||||
|
@ -262,7 +262,7 @@ fn read_write_loop<I: WriteableTmpFile>(
|
||||||
/// Write the lines in `chunk` to `file`, separated by `separator`.
|
/// Write the lines in `chunk` to `file`, separated by `separator`.
|
||||||
/// `compress_prog` is used to optionally compress file contents.
|
/// `compress_prog` is used to optionally compress file contents.
|
||||||
fn write<I: WriteableTmpFile>(
|
fn write<I: WriteableTmpFile>(
|
||||||
chunk: &mut Chunk,
|
chunk: &Chunk,
|
||||||
file: (File, PathBuf),
|
file: (File, PathBuf),
|
||||||
compress_prog: Option<&str>,
|
compress_prog: Option<&str>,
|
||||||
separator: u8,
|
separator: u8,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue