Skip to content

Commit b186f1f

Browse files
authored
Merge pull request #7339 from jfinkels/clippy-fixes-3
Style fixes from cargo +nightly clippy
2 parents 693d2c4 + faf3412 commit b186f1f

File tree

9 files changed

+13
-9
lines changed

9 files changed

+13
-9
lines changed

src/bin/coreutils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ fn main() {
107107
}
108108
// Not a special command: fallthrough to calling a util
109109
_ => {}
110-
};
110+
}
111111

112112
match utils.get(util) {
113113
Some(&(uumain, _)) => {

src/uu/expand/src/expand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ fn expand_line(
425425
// now dump out either spaces if we're expanding, or a literal tab if we're not
426426
if init || !options.iflag {
427427
if nts <= options.tspaces.len() {
428-
output.write_all(options.tspaces[..nts].as_bytes())?;
428+
output.write_all(&options.tspaces.as_bytes()[..nts])?;
429429
} else {
430430
output.write_all(" ".repeat(nts).as_bytes())?;
431431
};

src/uu/mkdir/src/mkdir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ fn exec(dirs: ValuesRef<OsString>, recursive: bool, mode: u32, verbose: bool) ->
152152
/// ## Options
153153
///
154154
/// * `recursive` --- create parent directories for the `path`, if they do not
155-
/// exist.
155+
/// exist.
156156
/// * `mode` --- file mode for the directories (not implemented on windows).
157157
/// * `verbose` --- print a message for each printed directory.
158158
///

src/uu/mktemp/src/mktemp.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,8 @@ fn dry_exec(tmpdir: &Path, prefix: &str, rand: usize, suffix: &str) -> UResult<P
424424
let len = prefix.len() + suffix.len() + rand;
425425
let mut buf = Vec::with_capacity(len);
426426
buf.extend(prefix.as_bytes());
427+
// In Rust v1.82.0, use `repeat_n`:
428+
// <https://doc.rust-lang.org/std/iter/fn.repeat_n.html>
427429
buf.extend(iter::repeat(b'X').take(rand));
428430
buf.extend(suffix.as_bytes());
429431

src/uu/sort/src/chunks.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,12 @@ fn parse_lines<'a>(
227227
///
228228
/// * `file`: The file to start reading from.
229229
/// * `next_files`: When `file` reaches EOF, it is updated to `next_files.next()` if that is `Some`,
230-
/// and this function continues reading.
230+
/// and this function continues reading.
231231
/// * `buffer`: The buffer that is filled with bytes. Its contents will mostly be overwritten (see `start_offset`
232232
/// as well). It will be grown up to `max_buffer_size` if necessary, but it will always grow to read at least two lines.
233233
/// * `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.
234234
/// * `start_offset`: The amount of bytes at the start of `buffer` that were carried over
235-
/// from the previous read and should not be overwritten.
235+
/// from the previous read and should not be overwritten.
236236
/// * `separator`: The byte that separates lines.
237237
///
238238
/// # Returns

src/uu/tail/src/chunks.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl BytesChunk {
141141
///
142142
/// * `chunk`: The chunk to create a new `BytesChunk` chunk from
143143
/// * `offset`: Start to copy the old chunk's buffer from this position. May not be larger
144-
/// than `chunk.bytes`.
144+
/// than `chunk.bytes`.
145145
///
146146
/// # Examples
147147
///
@@ -477,7 +477,7 @@ impl LinesChunk {
477477
/// # Arguments
478478
///
479479
/// * `offset`: the offset in number of lines. If offset is 0 then 0 is returned, if larger than
480-
/// the contained lines then self.bytes is returned.
480+
/// the contained lines then self.bytes is returned.
481481
///
482482
/// # Examples
483483
///

src/uu/tr/src/operation.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ impl Sequence {
132132
Self::Char(c) => Box::new(std::iter::once(*c)),
133133
Self::CharRange(l, r) => Box::new(*l..=*r),
134134
Self::CharStar(c) => Box::new(std::iter::repeat(*c)),
135+
// In Rust v1.82.0, use `repeat_n`:
136+
// <https://doc.rust-lang.org/std/iter/fn.repeat_n.html>
135137
Self::CharRepeat(c, n) => Box::new(std::iter::repeat(*c).take(*n)),
136138
Self::Class(class) => match class {
137139
Class::Alnum => Box::new((b'0'..=b'9').chain(b'A'..=b'Z').chain(b'a'..=b'z')),

src/uucore/src/lib/features/checksum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,7 @@ pub fn digest_reader<T: Read>(
10611061
Ok((digest.result_str(), output_size))
10621062
} else {
10631063
// Assume it's SHAKE. result_str() doesn't work with shake (as of 8/30/2016)
1064-
let mut bytes = vec![0; (output_bits + 7) / 8];
1064+
let mut bytes = vec![0; output_bits.div_ceil(8)];
10651065
digest.hash_finalize(&mut bytes);
10661066
Ok((hex::encode(bytes), output_size))
10671067
}

src/uucore/src/lib/features/sum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub trait Digest {
2727
fn reset(&mut self);
2828
fn output_bits(&self) -> usize;
2929
fn output_bytes(&self) -> usize {
30-
(self.output_bits() + 7) / 8
30+
self.output_bits().div_ceil(8)
3131
}
3232
fn result_str(&mut self) -> String {
3333
let mut buf: Vec<u8> = vec![0; self.output_bytes()];

0 commit comments

Comments
 (0)