diff options
author | Clement Tsang <34804052+ClementTsang@users.noreply.github.com> | 2020-05-18 23:34:50 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-18 23:34:50 -0400 |
commit | e6379982f17acedf964eaccd1c099da311e58bb3 (patch) | |
tree | 8c84ed99ec7832c9f9b7780c06fa00460183cd28 /src/canvas/widgets/cpu_basic.rs | |
parent | 12e4777d97b98987991ce4670df477108356b42f (diff) |
refactor: reduce unchecked type conversions to usize
Diffstat (limited to 'src/canvas/widgets/cpu_basic.rs')
-rw-r--r-- | src/canvas/widgets/cpu_basic.rs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/canvas/widgets/cpu_basic.rs b/src/canvas/widgets/cpu_basic.rs index 858b1732..baa6adbf 100644 --- a/src/canvas/widgets/cpu_basic.rs +++ b/src/canvas/widgets/cpu_basic.rs @@ -47,7 +47,7 @@ impl CpuBasicWidget for Painter { let num_cpus = cpu_data.len(); if draw_loc.height > 0 { - let remaining_height = draw_loc.height as usize; + let remaining_height = usize::from(draw_loc.height); const REQUIRED_COLUMNS: usize = 4; let chunk_vec = @@ -60,8 +60,7 @@ impl CpuBasicWidget for Painter { // +9 due to 3 + 4 + 2 columns for the name & space + percentage + bar bounds const MARGIN_SPACE: usize = 2; let remaining_width = usize::from(draw_loc.width) - .saturating_sub((9 + MARGIN_SPACE) * REQUIRED_COLUMNS - MARGIN_SPACE) - as usize; + .saturating_sub((9 + MARGIN_SPACE) * REQUIRED_COLUMNS - MARGIN_SPACE); let bar_length = remaining_width / REQUIRED_COLUMNS; @@ -112,7 +111,7 @@ impl CpuBasicWidget for Painter { Text::Styled( (&cpu_bars[cpu_index]).into(), self.colours.cpu_colour_styles - [cpu_index as usize % self.colours.cpu_colour_styles.len()], + [cpu_index % self.colours.cpu_colour_styles.len()], ) }) .collect::<Vec<_>>(); |