refactors: unwraps() removed, and/or map_or() used

This commit is contained in:
Jack Wills
2022-09-07 02:53:28 +00:00
parent 6c1aebd500
commit eb25744472
5 changed files with 41 additions and 33 deletions
+2 -2
View File
@@ -279,8 +279,8 @@ pub fn chart<B: Backend>(
.style(Style::default().fg(Color::Cyan))
.graph_type(GraphType::Line)
.data(&mem.0)];
let cpu_stats = CpuStats::new(cpu.0.last().unwrap_or(&(0.00, 0.00)).1);
let mem_stats = ByteStats::new(mem.0.last().unwrap_or(&(0.0, 0.0)).1 as u64);
let cpu_stats = CpuStats::new(cpu.0.last().map_or(0.00, |f| f.1));
let mem_stats = ByteStats::new(mem.0.last().map_or(0, |f| f.1 as u64));
let cpu_chart = make_chart(&cpu.2, "cpu", cpu_dataset, &cpu_stats, &cpu.1);
let mem_chart = make_chart(&mem.2, "memory", mem_dataset, &mem_stats, &mem.1);