Skip to content

Commit 8ae2049

Browse files
committed
避免除0
1 parent a70b4f3 commit 8ae2049

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

common/src/console_out/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ pub fn console_chart_a(chart_a: ChartA) {
268268
let up_max_value = *chart_a.up_map.values().max().unwrap_or(&0);
269269
let down_max_value = *chart_a.down_map.values().max().unwrap_or(&0);
270270
let max_value = up_max_value.max(down_max_value);
271+
let max_value = max_value.max(1);
271272
let max_height = 50;
272273
// 打印条形图
273274
for key in &keys {
@@ -342,6 +343,7 @@ pub fn console_chart_b(chart_b: ChartB) {
342343
}
343344
fn console_chart_b_list(list: Vec<usize>) {
344345
let max_value = *list.iter().max().unwrap_or(&0);
346+
let max_value = max_value.max(1);
345347
let max_height = max_value.min(20);
346348
// 遍历从最大高度到0
347349
for i in (0..=max_height).rev() {

0 commit comments

Comments
 (0)