mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-08-07 08:27:46 +00:00
Style fixes from cargo +nightly clippy
This commit is contained in:
parent
693d2c4258
commit
faf3412019
9 changed files with 13 additions and 9 deletions
|
@ -107,7 +107,7 @@ fn main() {
|
|||
}
|
||||
// Not a special command: fallthrough to calling a util
|
||||
_ => {}
|
||||
};
|
||||
}
|
||||
|
||||
match utils.get(util) {
|
||||
Some(&(uumain, _)) => {
|
||||
|
|
|
@ -425,7 +425,7 @@ fn expand_line(
|
|||
// now dump out either spaces if we're expanding, or a literal tab if we're not
|
||||
if init || !options.iflag {
|
||||
if nts <= options.tspaces.len() {
|
||||
output.write_all(options.tspaces[..nts].as_bytes())?;
|
||||
output.write_all(&options.tspaces.as_bytes()[..nts])?;
|
||||
} else {
|
||||
output.write_all(" ".repeat(nts).as_bytes())?;
|
||||
};
|
||||
|
|
|
@ -152,7 +152,7 @@ fn exec(dirs: ValuesRef<OsString>, recursive: bool, mode: u32, verbose: bool) ->
|
|||
/// ## Options
|
||||
///
|
||||
/// * `recursive` --- create parent directories for the `path`, if they do not
|
||||
/// exist.
|
||||
/// exist.
|
||||
/// * `mode` --- file mode for the directories (not implemented on windows).
|
||||
/// * `verbose` --- print a message for each printed directory.
|
||||
///
|
||||
|
|
|
@ -424,6 +424,8 @@ fn dry_exec(tmpdir: &Path, prefix: &str, rand: usize, suffix: &str) -> UResult<P
|
|||
let len = prefix.len() + suffix.len() + rand;
|
||||
let mut buf = Vec::with_capacity(len);
|
||||
buf.extend(prefix.as_bytes());
|
||||
// In Rust v1.82.0, use `repeat_n`:
|
||||
// <https://doc.rust-lang.org/std/iter/fn.repeat_n.html>
|
||||
buf.extend(iter::repeat(b'X').take(rand));
|
||||
buf.extend(suffix.as_bytes());
|
||||
|
||||
|
|
|
@ -227,12 +227,12 @@ fn parse_lines<'a>(
|
|||
///
|
||||
/// * `file`: The file to start reading from.
|
||||
/// * `next_files`: When `file` reaches EOF, it is updated to `next_files.next()` if that is `Some`,
|
||||
/// and this function continues reading.
|
||||
/// and this function continues reading.
|
||||
/// * `buffer`: The buffer that is filled with bytes. Its contents will mostly be overwritten (see `start_offset`
|
||||
/// as well). It will be grown up to `max_buffer_size` if necessary, but it will always grow to read at least two lines.
|
||||
/// * `max_buffer_size`: Grow the buffer to at most this length. If None, the buffer will not grow, unless needed to read at least two lines.
|
||||
/// * `start_offset`: The amount of bytes at the start of `buffer` that were carried over
|
||||
/// from the previous read and should not be overwritten.
|
||||
/// from the previous read and should not be overwritten.
|
||||
/// * `separator`: The byte that separates lines.
|
||||
///
|
||||
/// # Returns
|
||||
|
|
|
@ -141,7 +141,7 @@ impl BytesChunk {
|
|||
///
|
||||
/// * `chunk`: The chunk to create a new `BytesChunk` chunk from
|
||||
/// * `offset`: Start to copy the old chunk's buffer from this position. May not be larger
|
||||
/// than `chunk.bytes`.
|
||||
/// than `chunk.bytes`.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
@ -477,7 +477,7 @@ impl LinesChunk {
|
|||
/// # Arguments
|
||||
///
|
||||
/// * `offset`: the offset in number of lines. If offset is 0 then 0 is returned, if larger than
|
||||
/// the contained lines then self.bytes is returned.
|
||||
/// the contained lines then self.bytes is returned.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
|
|
@ -132,6 +132,8 @@ impl Sequence {
|
|||
Self::Char(c) => Box::new(std::iter::once(*c)),
|
||||
Self::CharRange(l, r) => Box::new(*l..=*r),
|
||||
Self::CharStar(c) => Box::new(std::iter::repeat(*c)),
|
||||
// In Rust v1.82.0, use `repeat_n`:
|
||||
// <https://doc.rust-lang.org/std/iter/fn.repeat_n.html>
|
||||
Self::CharRepeat(c, n) => Box::new(std::iter::repeat(*c).take(*n)),
|
||||
Self::Class(class) => match class {
|
||||
Class::Alnum => Box::new((b'0'..=b'9').chain(b'A'..=b'Z').chain(b'a'..=b'z')),
|
||||
|
|
|
@ -1061,7 +1061,7 @@ pub fn digest_reader<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![0; (output_bits + 7) / 8];
|
||||
let mut bytes = vec![0; output_bits.div_ceil(8)];
|
||||
digest.hash_finalize(&mut bytes);
|
||||
Ok((hex::encode(bytes), output_size))
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ pub trait Digest {
|
|||
fn reset(&mut self);
|
||||
fn output_bits(&self) -> usize;
|
||||
fn output_bytes(&self) -> usize {
|
||||
(self.output_bits() + 7) / 8
|
||||
self.output_bits().div_ceil(8)
|
||||
}
|
||||
fn result_str(&mut self) -> String {
|
||||
let mut buf: Vec<u8> = vec![0; self.output_bytes()];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue