From 5480522ddbf4b1e6c18a932d87fa1df1694b048e Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Fri, 5 Dec 2025 20:29:15 -0500 Subject: [PATCH] cargo fmt --- benchmarks/src/lib.rs | 112 ++++++++++++++++++++--------------------- build.rs | 2 +- parsing/src/parsing.rs | 2 - src/widgets.rs | 8 ++- 4 files changed, 64 insertions(+), 60 deletions(-) diff --git a/benchmarks/src/lib.rs b/benchmarks/src/lib.rs index c2e7684..185ae5c 100644 --- a/benchmarks/src/lib.rs +++ b/benchmarks/src/lib.rs @@ -8,81 +8,81 @@ use criterion::{criterion_group, criterion_main, Criterion}; use pprof::ProfilerGuard; pub struct FlamegraphProfiler<'a> { - frequency: c_int, - active_profiler: Option>, + frequency: c_int, + active_profiler: Option>, } impl<'a> FlamegraphProfiler<'a> { - #[allow(dead_code)] - pub fn new(frequency: c_int) -> Self { - FlamegraphProfiler { - frequency, - active_profiler: None, - } - } + #[allow(dead_code)] + pub fn new(frequency: c_int) -> Self { + FlamegraphProfiler { + frequency, + active_profiler: None, + } + } } impl<'a> Profiler for FlamegraphProfiler<'a> { - fn start_profiling(&mut self, _benchmark_id: &str, _benchmark_dir: &Path) { - self.active_profiler = Some(ProfilerGuard::new(self.frequency).unwrap()); - } + fn start_profiling(&mut self, _benchmark_id: &str, _benchmark_dir: &Path) { + self.active_profiler = Some(ProfilerGuard::new(self.frequency).unwrap()); + } - fn stop_profiling(&mut self, _benchmark_id: &str, benchmark_dir: &Path) { - std::fs::create_dir_all(benchmark_dir).unwrap(); - let flamegraph_path = benchmark_dir.join("flamegraph.svg"); - let flamegraph_file = File::create(&flamegraph_path) - .expect("File system error while creating flamegraph.svg"); - if let Some(profiler) = self.active_profiler.take() { - profiler - .report() - .build() - .unwrap() - .flamegraph(flamegraph_file) - .expect("Error writing flamegraph"); - } - } + fn stop_profiling(&mut self, _benchmark_id: &str, benchmark_dir: &Path) { + std::fs::create_dir_all(benchmark_dir).unwrap(); + let flamegraph_path = benchmark_dir.join("flamegraph.svg"); + let flamegraph_file = File::create(&flamegraph_path) + .expect("File system error while creating flamegraph.svg"); + if let Some(profiler) = self.active_profiler.take() { + profiler + .report() + .build() + .unwrap() + .flamegraph(flamegraph_file) + .expect("Error writing flamegraph"); + } + } } #[allow(dead_code)] // this infact IS used by benchmarks fn custom_criterion() -> Criterion { - Criterion::default() - .warm_up_time(Duration::from_millis(250)) - .sample_size(1000) + Criterion::default() + .warm_up_time(Duration::from_millis(250)) + .sample_size(1000) } #[allow(dead_code)] // this infact IS used by benchmarks fn custom_criterion_flamegraph() -> Criterion { - custom_criterion().with_profiler(FlamegraphProfiler::new(100)) + custom_criterion().with_profiler(FlamegraphProfiler::new(100)) } fn mutli_split_function(c: &mut Criterion) { - let data_chars = vec![ - "sin(x)cos(x)", - "x^2", - "2x", - "log10(x)", - "E^x", - "xxxxx", - "xsin(x)", - "(2x+1)(3x+1)", - "x**2", - "pipipipipipix", - "pi(2x+1)", - "(2x+1)pi", - ] - .iter() - .map(|a| a.chars().collect::>()) - .collect::>>(); + let data_chars = vec![ + "sin(x)cos(x)", + "x^2", + "2x", + "log10(x)", + "E^x", + "xxxxx", + "xsin(x)", + "(2x+1)(3x+1)", + "x**2", + "pipipipipipix", + "pi(2x+1)", + "(2x+1)pi", + ] + .iter() + .map(|a| a.chars().collect::>()) + .collect::>>(); - let mut group = c.benchmark_group("split_function"); - for entry in data_chars { - group.bench_function(entry.iter().collect::(), |b| { - b.iter(|| { - split_function_chars(&entry, SplitType::Multiplication); - }) - }); - } - group.finish(); + let mut group = c.benchmark_group("split_function"); + for entry in data_chars { + group.bench_function(entry.iter().collect::(), |b| { + b.iter(|| { + split_function_chars(&entry, SplitType::Multiplication); + }) + }); + } + group.finish(); } // Uncomment to enable flamegraph profiling diff --git a/build.rs b/build.rs index d56d0a5..c02c013 100644 --- a/build.rs +++ b/build.rs @@ -6,8 +6,8 @@ use allsorts::{ tag, }; use epaint::{ - text::{FontData, FontDefinitions, FontTweak}, FontFamily, + text::{FontData, FontDefinitions, FontTweak}, }; use std::{ collections::BTreeMap, diff --git a/parsing/src/parsing.rs b/parsing/src/parsing.rs index 04f1dec..842ec96 100644 --- a/parsing/src/parsing.rs +++ b/parsing/src/parsing.rs @@ -138,8 +138,6 @@ impl BackingFunction { } } - - /// Case insensitive checks for if `c` is a character used to represent a variable #[inline] pub const fn is_variable(c: &char) -> bool { diff --git a/src/widgets.rs b/src/widgets.rs index a4585a5..2f927b1 100644 --- a/src/widgets.rs +++ b/src/widgets.rs @@ -19,7 +19,13 @@ pub fn widgets_ontop( /// A toggle button that XORs its state when clicked. /// Shows different hover text based on current state. -pub fn toggle_button(ui: &mut Ui, state: &mut bool, label: &str, enabled_tip: &str, disabled_tip: &str) { +pub fn toggle_button( + ui: &mut Ui, + state: &mut bool, + label: &str, + enabled_tip: &str, + disabled_tip: &str, +) { state.bitxor_assign( ui.add(Button::new(label)) .on_hover_text(if *state { enabled_tip } else { disabled_tip })