From 68322f37db5f69563a1d6e56a59c6c7205d07748 Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Thu, 3 Mar 2022 00:26:35 -0500 Subject: [PATCH] better handling of setting func_str to an empty string --- src/egui_app.rs | 4 ++-- src/function.rs | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/egui_app.rs b/src/egui_app.rs index fae0a3c..5abfbac 100644 --- a/src/egui_app.rs +++ b/src/egui_app.rs @@ -279,7 +279,7 @@ impl MathApp { ); } } else { - function.func_str = String::new(); + function.empty_func_str(); } } @@ -349,7 +349,7 @@ impl epi::App for MathApp { None, // Doesn't matter, updated later Some(self.settings.sum), ); - function.func_str = String::new(); + function.empty_func_str(); function }); self.func_strs.push(String::new()); diff --git a/src/function.rs b/src/function.rs index 6a753ec..5e427d6 100644 --- a/src/function.rs +++ b/src/function.rs @@ -23,7 +23,7 @@ impl fmt::Display for RiemannSum { pub struct Function { function: Box f64>, - pub(crate) func_str: String, + func_str: String, min_x: f64, max_x: f64, pixel_width: usize, @@ -248,4 +248,6 @@ impl Function { let area: f64 = data2.iter().map(|(_, y)| y * step).sum(); // sum of all rectangles' areas (data2, area) } + + pub fn empty_func_str(&mut self) { self.func_str = String::new(); } }