refactor: remove unused name attribute
This commit is contained in:
parent
7264d127d9
commit
93de64f4b9
2 changed files with 6 additions and 11 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue