fix additional clippy warnings.
This commit is contained in:
parent
0cbba6b290
commit
0105b29bfc
@ -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 {
|
||||
|
||||
@ -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],
|
||||
);
|
||||
|
||||
@ -79,8 +79,8 @@ async fn main() {
|
||||
let addr = SocketAddr::from(([0, 0, 0, 0], port));
|
||||
|
||||
//output to console
|
||||
println!("Remote agent running at http://{}", addr);
|
||||
println!("WebSocket endpoint: ws://{}/ws", addr);
|
||||
println!("Remote agent running at http://{addr}");
|
||||
println!("WebSocket endpoint: ws://{addr}/ws");
|
||||
|
||||
//trace logging
|
||||
tracing::info!("Remote agent running at http://{} (ws at /ws)", addr);
|
||||
@ -103,8 +103,7 @@ fn resolve_port() -> u16 {
|
||||
}
|
||||
}
|
||||
eprintln!(
|
||||
"Warning: invalid SOCKTOP_PORT='{}'; using default {}",
|
||||
s, DEFAULT
|
||||
"Warning: invalid SOCKTOP_PORT='{s}'; using default {DEFAULT}"
|
||||
);
|
||||
}
|
||||
|
||||
@ -116,12 +115,12 @@ fn resolve_port() -> u16 {
|
||||
match v.parse::<u16>() {
|
||||
Ok(p) if p != 0 => return p,
|
||||
_ => {
|
||||
eprintln!("Invalid port '{}'; using default {}", v, DEFAULT);
|
||||
eprintln!("Invalid port '{v}'; using default {DEFAULT}");
|
||||
return DEFAULT;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
eprintln!("Missing value for {} ; using default {}", arg, DEFAULT);
|
||||
eprintln!("Missing value for {arg} ; using default {DEFAULT}");
|
||||
return DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user