From b28a652aef446c3dfb1276edea7d26533ac8952c Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Thu, 24 Feb 2022 11:20:05 -0500 Subject: [PATCH] rustfmt --- src/chart_manager.rs | 10 +++++----- src/egui_app.rs | 16 +++++----------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/chart_manager.rs b/src/chart_manager.rs index 627cf78..c3f4832 100644 --- a/src/chart_manager.rs +++ b/src/chart_manager.rs @@ -1,6 +1,5 @@ use crate::misc::{add_asterisks, Function}; - pub enum UpdateType { FULL, FRONT, @@ -34,9 +33,9 @@ impl ChartManager { pub fn draw_back(&mut self) -> Vec<(f64, f64)> { let absrange = (self.max_x - self.min_x).abs(); let output: Vec<(f64, f64)> = (1..=self.resolution) - .map(|x| ((x as f64 / self.resolution as f64) * absrange) + self.min_x) - .map(|x| (x, self.function.run(x))) - .collect(); + .map(|x| ((x as f64 / self.resolution as f64) * absrange) + self.min_x) + .map(|x| (x, self.function.run(x))) + .collect(); output } @@ -57,7 +56,8 @@ impl ChartManager { let update_func: bool = !self.function.str_compare(func_str.clone()); let update_back = update_func | (min_x != self.min_x) | (max_x != self.max_x); - let update_front = update_back | (self.resolution != resolution) | (num_interval != self.num_interval); + let update_front = + update_back | (self.resolution != resolution) | (num_interval != self.num_interval); if update_func { self.function = Function::from_string(func_str); diff --git a/src/egui_app.rs b/src/egui_app.rs index 4d69365..703719f 100644 --- a/src/egui_app.rs +++ b/src/egui_app.rs @@ -13,7 +13,7 @@ pub struct MathApp { resolution: usize, chart_manager: ChartManager, back_cache: Cache>, - front_cache: Cache<(Vec, f64)> + front_cache: Cache<(Vec, f64)>, } impl Default for MathApp { @@ -54,7 +54,7 @@ impl MathApp { } else { let (data, area) = self.chart_manager.draw_front(); let bars: Vec = data.iter().map(|(x, y)| Bar::new(*x, *y)).collect(); - + let output = (bars, area); self.front_cache.set(output.clone()); output @@ -68,7 +68,6 @@ impl MathApp { } } - impl epi::App for MathApp { fn name(&self) -> &str { "Integral Demonstration" } @@ -138,19 +137,14 @@ impl epi::App for MathApp { ); }); - let do_update = chart_manager.update( - func_str.clone(), - *min_x, - *max_x, - *num_interval, - *resolution, - ); + let do_update = + chart_manager.update(func_str.clone(), *min_x, *max_x, *num_interval, *resolution); match do_update { UpdateType::FULL => { back_cache.invalidate(); front_cache.invalidate(); - }, + } UpdateType::BACK => back_cache.invalidate(), UpdateType::FRONT => front_cache.invalidate(), _ => {}