fix additional clippy warnings.

This commit is contained in:
2025-08-11 14:34:45 -07:00
parent 0cbba6b290
commit 0105b29bfc
3 changed files with 15 additions and 15 deletions
+3 -3
View File
@@ -135,7 +135,7 @@ pub fn per_core_handle_scrollbar_mouse(
if track == 0 {
return;
}
let thumb_len = ((track * view + total - 1) / total).max(1).min(track);
let thumb_len = (track * view).div_ceil(total).max(1).min(track);
let top_for_offset = |off: usize| -> usize {
if max_off == 0 {
0
@@ -340,7 +340,7 @@ pub fn draw_per_core_bars(
let spark = Sparkline::default().data(&hist).max(100).style(Style::default().fg(fg));
f.render_widget(spark, hchunks[0]);
let label = format!("cpu{:<2}{}{:>5.1}%", idx, trend, curr);
let label = format!("cpu{idx:<2}{trend}{curr:>5.1}%");
let line = Line::from(Span::styled(
label,
Style::default().fg(fg).add_modifier(Modifier::BOLD),
@@ -361,7 +361,7 @@ pub fn draw_per_core_bars(
let view = viewport_rows.clamp(1, total);
let max_off = total.saturating_sub(view);
let thumb_len = ((track * view + total - 1) / total).max(1).min(track);
let thumb_len = (track * view).div_ceil(total).max(1).min(track);
let thumb_top = if max_off == 0 {
0
} else {
+7 -6
View File
@@ -15,7 +15,7 @@ fn fmt_bytes(b: u64) -> String {
if fb >= GB { format!("{:.1}G", fb / GB) }
else if fb >= MB { format!("{:.1}M", fb / MB) }
else if fb >= KB { format!("{:.1}K", fb / KB) }
else { format!("{}B", b) }
else { format!("{b}B") }
}
pub fn draw_gpu(f: &mut ratatui::Frame<'_>, area: Rect, m: Option<&Metrics>) {
@@ -52,9 +52,7 @@ pub fn draw_gpu(f: &mut ratatui::Frame<'_>, area: Rect, m: Option<&Metrics>) {
let max_gpus = (area.height / per_gpu_rows) as usize;
let count = gpus.len().min(max_gpus);
let constraints = std::iter::repeat(Constraint::Length(1))
.take(count * per_gpu_rows as usize)
.collect::<Vec<_>>();
let constraints = vec![Constraint::Length(1); count * per_gpu_rows as usize];
let rows = Layout::default()
.direction(Direction::Vertical)
.constraints(constraints)
@@ -74,7 +72,7 @@ pub fn draw_gpu(f: &mut ratatui::Frame<'_>, area: Rect, m: Option<&Metrics>) {
for i in 0..count {
let g = &gpus[i];
// Row 1: GPU name (and temp can be appended later)
// Row 1: GPU name
let name_text = g.name.clone();
f.render_widget(
Paragraph::new(Span::raw(name_text)).style(Style::default().fg(Color::Gray)),
@@ -106,8 +104,11 @@ pub fn draw_gpu(f: &mut ratatui::Frame<'_>, area: Rect, m: Option<&Metrics>) {
.label(Span::raw(""))
.ratio(mem_ratio);
f.render_widget(mem_gauge, mem_cols[0]);
// Prepare strings to enable captured identifiers in format!
let used_s = fmt_bytes(used);
let total_s = fmt_bytes(total);
f.render_widget(
Paragraph::new(Span::raw(format!("vram: {}/{} ({mem_pct}%)", fmt_bytes(used), fmt_bytes(total))))
Paragraph::new(Span::raw(format!("vram: {used_s}/{total_s} ({mem_pct}%)")))
.style(Style::default().fg(Color::Gray)),
mem_cols[1],
);