mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
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
This commit is contained in:
@@ -244,9 +244,7 @@ fn find_kp_breakpoints<'a, T: Iterator<Item = &'a WordInfo<'a>>>(
|
||||
let mut new_linebreaks = vec![];
|
||||
let mut is_sentence_start = false;
|
||||
let mut least_demerits = 0;
|
||||
loop {
|
||||
let Some(w) = iter.next() else { break };
|
||||
|
||||
while let Some(w) = iter.next() {
|
||||
// if this is the last word, we don't add additional demerits for this break
|
||||
let (is_last_word, is_sentence_end) = match iter.peek() {
|
||||
None => (true, true),
|
||||
|
||||
@@ -291,14 +291,14 @@ impl BytesChunkBuffer {
|
||||
// fill chunks with all bytes from reader and reuse already instantiated chunks if possible
|
||||
while chunk.fill(reader)?.is_some() {
|
||||
self.bytes += chunk.bytes as u64;
|
||||
self.chunks.push_back(chunk);
|
||||
self.chunks.push_back(chunk.clone());
|
||||
|
||||
let first = &self.chunks[0];
|
||||
if self.bytes - first.bytes as u64 > self.num_print {
|
||||
chunk = self.chunks.pop_front().unwrap();
|
||||
self.bytes -= chunk.bytes as u64;
|
||||
} else {
|
||||
chunk = Box::new(BytesChunk::new());
|
||||
*chunk = BytesChunk::new();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -333,7 +333,7 @@ impl BytesChunkBuffer {
|
||||
|
||||
/// Works similar to a [`BytesChunk`] but also stores the number of lines encountered in the current
|
||||
/// buffer. The size of the buffer is limited to a fixed size number of bytes.
|
||||
#[derive(Debug)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct LinesChunk {
|
||||
/// Work on top of a [`BytesChunk`]
|
||||
chunk: BytesChunk,
|
||||
@@ -567,7 +567,7 @@ impl LinesChunkBuffer {
|
||||
|
||||
while chunk.fill(reader)?.is_some() {
|
||||
self.lines += chunk.lines as u64;
|
||||
self.chunks.push_back(chunk);
|
||||
self.chunks.push_back(chunk.clone());
|
||||
|
||||
let first = &self.chunks[0];
|
||||
if self.lines - first.lines as u64 > self.num_print {
|
||||
@@ -575,7 +575,7 @@ impl LinesChunkBuffer {
|
||||
|
||||
self.lines -= chunk.lines as u64;
|
||||
} else {
|
||||
chunk = Box::new(LinesChunk::new(self.delimiter));
|
||||
*chunk = LinesChunk::new(self.delimiter);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user