refactor: use map_or_else

This commit is contained in:
Jack Wills
2022-10-02 00:31:01 +00:00
parent a7b8df6b21
commit f5fc446295
5 changed files with 38 additions and 33 deletions
+2 -3
View File
@@ -78,9 +78,8 @@ impl DockerData {
.cpu_stats
.cpu_usage
.percpu_usage
.clone()
.unwrap_or_default()
.len() as u64
.as_ref()
.map_or_else(|| 0, |i| i.len()) as u64
}) as f64;
if system_delta > 0.0 && cpu_delta > 0.0 {
cpu_percentage = (cpu_delta / system_delta) * online_cpus * 100.0;