From a72041482f2cc77210ef0a86ac14c083d7091809 Mon Sep 17 00:00:00 2001 From: "M.Amin Rayej" Date: Mon, 19 Feb 2024 07:55:00 +0330 Subject: [PATCH] use drain instead of slice index --- lib/cli/src/commands/app/logs.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/cli/src/commands/app/logs.rs b/lib/cli/src/commands/app/logs.rs index b4f134325d3..aa15c686eaf 100644 --- a/lib/cli/src/commands/app/logs.rs +++ b/lib/cli/src/commands/app/logs.rs @@ -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; } }