From 66d9ff301c3167fb5a64153ef8b248589b67f172 Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Wed, 23 Feb 2022 19:43:27 -0500 Subject: [PATCH] rustfmt --- src/egui_app.rs | 37 +++++++++++++++---------------------- src/lib.rs | 1 - 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/src/egui_app.rs b/src/egui_app.rs index e74735b..a16ee6b 100644 --- a/src/egui_app.rs +++ b/src/egui_app.rs @@ -1,11 +1,9 @@ use crate::chart_manager::ChartManager; use crate::misc::{digits_precision, test_func, Cache}; use eframe::{egui, epi}; +use egui::plot::{Line, Plot, Value, Values}; use egui::widgets::plot::{Bar, BarChart}; -use egui::{ - plot::{Line, Plot, Value, Values}, -}; -use egui::{Color32, plot}; +use egui::{plot, Color32}; pub struct MathApp { func_str: String, @@ -77,7 +75,7 @@ impl epi::App for MathApp { let min_x_response = ui.add(egui::Slider::new(min_x, x_range.clone()).text("Min X")); let max_x_old = max_x.clone(); - let max_x_response = ui.add(egui::Slider::new(max_x, x_range).text("Max X")); + let max_x_response = ui.add(egui::Slider::new(max_x, x_range).text("Max X")); if min_x >= max_x { if max_x_response.changed() { @@ -90,12 +88,9 @@ impl epi::App for MathApp { } } - - ui.add(egui::Slider::new(num_interval, 1..=usize::MAX).text("Interval")); }); - let update_back = chart_manager.do_update_back(func_str.clone(), *min_x, *max_x); let update_front = chart_manager.do_update_front(*num_interval, *resolution); @@ -122,30 +117,24 @@ impl epi::App for MathApp { let bars: Vec = match update_front { true => { - let bars: Vec = rect_data - .iter() - .map(|(x, y)| Bar::new(*x, *y)) - .collect(); - + let bars: Vec = rect_data.iter().map(|(x, y)| Bar::new(*x, *y)).collect(); + bar_cache.set(bars.clone()); bars - }, + } false => { if bar_cache.is_valid() { bar_cache.get().clone() } else { - let bars: Vec = rect_data - .iter() - .map(|(x, y)| Bar::new(*x, *y)) - .collect(); - + let bars: Vec = + rect_data.iter().map(|(x, y)| Bar::new(*x, *y)).collect(); + bar_cache.set(bars.clone()); bars } - }, + } }; let bar_chart = BarChart::new(bars).color(Color32::BLUE); - Plot::new("plot") .view_aspect(1.0) @@ -157,7 +146,11 @@ impl epi::App for MathApp { let duration = start.elapsed(); - ui.label(format!("Area: {} Took: {:?}", digits_precision(area, 8), duration)); + ui.label(format!( + "Area: {} Took: {:?}", + digits_precision(area, 8), + duration + )); }); } } diff --git a/src/lib.rs b/src/lib.rs index 4cb0d99..ad10bf2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,7 +5,6 @@ mod chart_manager; mod egui_app; mod misc; - #[cfg(target_arch = "wasm32")] use eframe::{egui, epi};