Skip to content

Commit 01c0a61

Browse files
authored
clippy: fix warnings from nightly (#8991)
* uu: addressing clippy warning, find_kp_breakpoints modernize while loop. * however here clippy advice do not seem a gain. yes we can vave Box::new but then we have to clone the chunk.. * feedback, remove also too recent clippy annotation
1 parent 8fbd089 commit 01c0a61

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/uu/fmt/src/linebreak.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,7 @@ fn find_kp_breakpoints<'a, T: Iterator<Item = &'a WordInfo<'a>>>(
244244
let mut new_linebreaks = vec![];
245245
let mut is_sentence_start = false;
246246
let mut least_demerits = 0;
247-
loop {
248-
let Some(w) = iter.next() else { break };
249-
247+
while let Some(w) = iter.next() {
250248
// if this is the last word, we don't add additional demerits for this break
251249
let (is_last_word, is_sentence_end) = match iter.peek() {
252250
None => (true, true),

src/uu/tail/src/chunks.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -291,14 +291,14 @@ impl BytesChunkBuffer {
291291
// fill chunks with all bytes from reader and reuse already instantiated chunks if possible
292292
while chunk.fill(reader)?.is_some() {
293293
self.bytes += chunk.bytes as u64;
294-
self.chunks.push_back(chunk);
294+
self.chunks.push_back(chunk.clone());
295295

296296
let first = &self.chunks[0];
297297
if self.bytes - first.bytes as u64 > self.num_print {
298298
chunk = self.chunks.pop_front().unwrap();
299299
self.bytes -= chunk.bytes as u64;
300300
} else {
301-
chunk = Box::new(BytesChunk::new());
301+
*chunk = BytesChunk::new();
302302
}
303303
}
304304

@@ -333,7 +333,7 @@ impl BytesChunkBuffer {
333333

334334
/// Works similar to a [`BytesChunk`] but also stores the number of lines encountered in the current
335335
/// buffer. The size of the buffer is limited to a fixed size number of bytes.
336-
#[derive(Debug)]
336+
#[derive(Clone, Debug)]
337337
pub struct LinesChunk {
338338
/// Work on top of a [`BytesChunk`]
339339
chunk: BytesChunk,
@@ -567,15 +567,15 @@ impl LinesChunkBuffer {
567567

568568
while chunk.fill(reader)?.is_some() {
569569
self.lines += chunk.lines as u64;
570-
self.chunks.push_back(chunk);
570+
self.chunks.push_back(chunk.clone());
571571

572572
let first = &self.chunks[0];
573573
if self.lines - first.lines as u64 > self.num_print {
574574
chunk = self.chunks.pop_front().unwrap();
575575

576576
self.lines -= chunk.lines as u64;
577577
} else {
578-
chunk = Box::new(LinesChunk::new(self.delimiter));
578+
*chunk = LinesChunk::new(self.delimiter);
579579
}
580580
}
581581

0 commit comments

Comments
 (0)