From e4b3d9c4a4db404594b897ed83295dbf818e05d4 Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Tue, 1 Mar 2022 22:00:31 -0500 Subject: [PATCH] simplify some code --- src/egui_app.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/egui_app.rs b/src/egui_app.rs index 6de84af..015d736 100644 --- a/src/egui_app.rs +++ b/src/egui_app.rs @@ -375,13 +375,16 @@ impl epi::App for MathApp { let (back_values, bars) = function.run(); plot_ui.line(back_values.color(Color32::RED)); - if let Some(bars_data) = bars { - let (bar_chart, area) = bars_data; - plot_ui.bar_chart(bar_chart.color(Color32::BLUE).width(step)); - area_list.push(digits_precision(area, 8)) - } else { - area_list.push(f64::NAN); - } + area_list.push({ + if let Some(bars_data) = bars { + let (bar_chart, area) = bars_data; + plot_ui + .bar_chart(bar_chart.color(Color32::BLUE).width(step)); + digits_precision(area, 8) + } else { + f64::NAN + } + }); } }); });