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

View file

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