Skip to content

Commit

Permalink
use drain instead of slice index
Browse files Browse the repository at this point in the history
  • Loading branch information
maminrayej authored and theduke committed Feb 20, 2024
1 parent 91a7383 commit 83d39de
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/cli/src/commands/app/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,20 @@ impl crate::commands::AsyncCliCommand for CmdAppLogs {
let mut rem = self.max;

while let Some(logs) = logs_stream.next().await {
let logs = logs?;
let mut logs = logs?;

let limit = std::cmp::min(logs.len(), rem);

let logs = &logs[..limit];
let logs: Vec<_> = logs.drain(..limit).collect();

if !logs.is_empty() {
let rendered = self.fmt.format.render(logs);
let rendered = self.fmt.format.render(&logs);
println!("{rendered}");

rem -= limit;
}

if !self.watch && rem == 0 {
if !self.watch || rem == 0 {
break;
}
}
Expand Down

0 comments on commit 83d39de

Please sign in to comment.