refactor: remove unused name attribute

This commit is contained in:
electria 2026-08-15 18:42:53 -07:00
commit 93de64f4b9
Signed by: electria
SSH key fingerprint: SHA256:8LlB3ucPbBHqozqkhsNbaV5oG3SlzzqUj8FZDL6IPQs
2 changed files with 6 additions and 11 deletions

View file

@ -15,7 +15,7 @@ enum Message {
#[derive(Default)] #[derive(Default)]
struct State { struct State {
total_cpu_graph: CpuGraph, total_cpu_graph: CpuGraph,
cpu_graphs: Vec<(String, CpuGraph)>, cpu_graphs: Vec<CpuGraph>,
} }
impl State { impl State {
@ -51,11 +51,10 @@ impl State {
self.cpu_graphs = snapshot self.cpu_graphs = snapshot
.cpus .cpus
.into_iter() .into_iter()
.map(|(name, usage)| (name, CpuGraph::new(usage))) .map(|usage| CpuGraph::new(usage))
.collect(); .collect();
} else { } else {
for ((_, graph), (_, usage)) in for (graph, usage) in self.cpu_graphs.iter_mut().zip(snapshot.cpus.into_iter())
self.cpu_graphs.iter_mut().zip(snapshot.cpus.into_iter())
{ {
graph.update(usage); graph.update(usage);
graph.cache.clear(); graph.cache.clear();
@ -75,7 +74,7 @@ impl State {
widget::grid( widget::grid(
self.cpu_graphs self.cpu_graphs
.iter() .iter()
.map(|(_name, graph)| widget::Canvas::new(graph).into()), .map(|graph| widget::Canvas::new(graph).into()),
) )
.columns(2) .columns(2)
.height(Length::Fill) .height(Length::Fill)

View file

@ -1,18 +1,14 @@
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct SysinfoSnapshot { pub struct SysinfoSnapshot {
pub cpu_total: f32, pub cpu_total: f32,
pub cpus: Vec<(String, f32)>, pub cpus: Vec<f32>,
} }
impl From<&sysinfo::System> for SysinfoSnapshot { impl From<&sysinfo::System> for SysinfoSnapshot {
fn from(value: &sysinfo::System) -> Self { fn from(value: &sysinfo::System) -> Self {
Self { Self {
cpu_total: value.global_cpu_usage(), cpu_total: value.global_cpu_usage(),
cpus: value cpus: value.cpus().iter().map(|cpu| cpu.cpu_usage()).collect(),
.cpus()
.iter()
.map(|cpu| (cpu.name().into(), cpu.cpu_usage()))
.collect(),
} }
} }
} }