Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/uu/tail/src/chunks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,14 +289,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.clone());
self.chunks.push_back(chunk);

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 = BytesChunk::new();
chunk = Box::new(BytesChunk::new());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: the change in this line is necessary to avoid:

error[E0382]: use of moved value: `chunk`
   --> src/uu/tail/src/chunks.rs:292:35

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you - checking what went wrong locally with tests, and why it missed this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wait i miss-read what you typed. My bad. Yes, the line 299 change is required.

}
}

Expand Down Expand Up @@ -563,15 +563,14 @@ impl LinesChunkBuffer {

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

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

self.lines -= chunk.lines as u64;
} else {
*chunk = LinesChunk::new(self.delimiter);
chunk = Box::new(LinesChunk::new(self.delimiter));
}
}

Expand Down
Loading