From 2a5e30b15e1dbf7a2151f8957a449aad51ed57ac Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Mon, 28 Feb 2022 13:22:02 -0500 Subject: [PATCH] better option handling --- src/egui_app.rs | 2 +- src/function.rs | 21 +++++++-------------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/egui_app.rs b/src/egui_app.rs index 219703c..2437a5c 100644 --- a/src/egui_app.rs +++ b/src/egui_app.rs @@ -180,7 +180,7 @@ impl epi::App for MathApp { let func_test_output = test_func(proc_func_str.clone()); if func_test_output.is_some() { parse_error += &format!("(Function #{}) ", i); - parse_error += &func_test_output.expect(""); + parse_error += &func_test_output.unwrap(); } else { function.update(proc_func_str, integral, Some(self.integral_min_x), Some(self.integral_max_x), Some(self.integral_num)); } diff --git a/src/function.rs b/src/function.rs index 6f51a35..709e23d 100644 --- a/src/function.rs +++ b/src/function.rs @@ -149,9 +149,9 @@ impl Function { | (integral_num != Some(self.integral_num)) { self.front_cache = None; - self.integral_min_x = integral_min_x.expect(""); - self.integral_max_x = integral_max_x.expect(""); - self.integral_num = integral_num.expect(""); + self.integral_min_x = integral_min_x.expect("integral_min_x is None"); + self.integral_max_x = integral_max_x.expect("integral_max_x is None"); + self.integral_num = integral_num.expect("integral_num is None"); } } } @@ -167,16 +167,9 @@ impl Function { let range_new: f64 = max_x.abs() + min_x.abs(); let resolution: f64 = (self.pixel_width as f64 / range_new) as f64; - let back_cache = self.back_cache.as_ref().expect(""); + let back_cache = self.back_cache.as_ref().unwrap(); - let x_data: Vec = self - .back_cache - .as_ref() - .expect("") - .clone() - .iter() - .map(|ele| ele.x) - .collect(); + let x_data: Vec = back_cache.iter().map(|ele| ele.x).collect(); self.back_cache = Some( (1..=self.pixel_width) @@ -210,7 +203,7 @@ impl Function { let back_values: Vec = match self.back_cache.is_some() { true => { debug_log("back_cache: using"); - self.back_cache.as_ref().expect("").clone() + self.back_cache.as_ref().unwrap().clone() } false => { debug_log("back_cache: regen"); @@ -232,7 +225,7 @@ impl Function { let front_bars: (Vec, f64) = match self.front_cache.is_some() { true => { debug_log("front_cache: using"); - let cache = self.front_cache.as_ref().expect(""); + let cache = self.front_cache.as_ref().unwrap(); let vec_bars: Vec = cache.0.to_vec(); (vec_bars, cache.1) }