From dfeb8164ca7b3825ca94b36a5d7da182f799ca68 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Fri, 6 Jan 2023 16:07:42 +0100 Subject: [PATCH] Fix new Clippy lints --- nih_plug_xtask/src/symbols.rs | 2 +- plugins/crisp/src/lib.rs | 3 +-- plugins/crossover/src/lib.rs | 4 ++-- plugins/examples/gain_gui_egui/src/lib.rs | 2 +- src/formatters.rs | 10 +++++----- src/params/float.rs | 4 ++-- src/params/integer.rs | 2 +- src/wrapper/vst3/param_units.rs | 1 - 8 files changed, 13 insertions(+), 15 deletions(-) diff --git a/nih_plug_xtask/src/symbols.rs b/nih_plug_xtask/src/symbols.rs index 12d24c2c..7bcca3b4 100644 --- a/nih_plug_xtask/src/symbols.rs +++ b/nih_plug_xtask/src/symbols.rs @@ -24,7 +24,7 @@ pub fn exported>(binary: P, symbol: &str) -> Result { }; // XXX: Why are all exported symbols on macOS prefixed with an underscore? - let symbol = format!("_{}", symbol); + let symbol = format!("_{symbol}"); Ok(obj.exports()?.into_iter().any(|sym| sym.name == symbol)) } diff --git a/plugins/crisp/src/lib.rs b/plugins/crisp/src/lib.rs index d3f4ab3a..57a4be03 100644 --- a/plugins/crisp/src/lib.rs +++ b/plugins/crisp/src/lib.rs @@ -144,7 +144,6 @@ impl Default for Crisp { } impl Default for CrispParams { - #[allow(clippy::derivable_impls)] fn default() -> Self { let f32_hz_then_khz = formatters::v2s_f32_hz_then_khz(0); let from_f32_hz_then_khz = formatters::s2v_f32_hz_then_khz(); @@ -176,7 +175,7 @@ impl Default for CrispParams { if value >= MAX_FILTER_FREQUENCY { String::from("Disabled") } else { - format!("{:.0} Hz", value) + format!("{value:.0} Hz") } })) .with_string_to_value(Arc::new(|string| { diff --git a/plugins/crossover/src/lib.rs b/plugins/crossover/src/lib.rs index bb4147e4..7d206ce0 100644 --- a/plugins/crossover/src/lib.rs +++ b/plugins/crossover/src/lib.rs @@ -127,8 +127,8 @@ impl CrossoverParams { .with_string_to_value(crossover_string_to_value.clone()), crossover_4_freq: FloatParam::new("Crossover 4", 10000.0, crossover_range) .with_smoother(crossover_smoothing_style) - .with_value_to_string(crossover_value_to_string.clone()) - .with_string_to_value(crossover_string_to_value.clone()), + .with_value_to_string(crossover_value_to_string) + .with_string_to_value(crossover_string_to_value), crossover_type: EnumParam::new("Type", CrossoverType::LinkwitzRiley24).with_callback( Arc::new(move |_| should_update_filters.store(true, Ordering::Relaxed)), diff --git a/plugins/examples/gain_gui_egui/src/lib.rs b/plugins/examples/gain_gui_egui/src/lib.rs index d8c62fa8..38ec79e6 100644 --- a/plugins/examples/gain_gui_egui/src/lib.rs +++ b/plugins/examples/gain_gui_egui/src/lib.rs @@ -133,7 +133,7 @@ impl Plugin for Gain { let peak_meter = util::gain_to_db(peak_meter.load(std::sync::atomic::Ordering::Relaxed)); let peak_meter_text = if peak_meter > util::MINUS_INFINITY_DB { - format!("{:.1} dBFS", peak_meter) + format!("{peak_meter:.1} dBFS") } else { String::from("-inf dBFS") }; diff --git a/src/formatters.rs b/src/formatters.rs index ff512100..a5436ee9 100644 --- a/src/formatters.rs +++ b/src/formatters.rs @@ -15,7 +15,7 @@ use crate::util; /// Round an `f32` value to always have a specific number of decimal digits. pub fn v2s_f32_rounded(digits: usize) -> Arc String + Send + Sync> { - Arc::new(move |value| format!("{:.digits$}", value)) + Arc::new(move |value| format!("{value:.digits$}")) } /// Format a `[0, 1]` number as a percentage. Does not include the percent sign, you should specify @@ -41,7 +41,7 @@ pub fn s2v_f32_percentage() -> Arc Option + Send + Sync> { pub fn v2s_compression_ratio(digits: usize) -> Arc String + Send + Sync> { Arc::new(move |value| { if value >= 1.0 { - format!("{:.digits$}:1", value) + format!("{value:.digits$}:1") } else { format!("1:{:.digits$}", value.recip()) } @@ -79,7 +79,7 @@ pub fn v2s_f32_gain_to_db(digits: usize) -> Arc String + Send + S let value_db = util::gain_to_db(value); let value_db = if value_db.abs() < 1e-6 { 0.0 } else { value_db }; - format!("{:.digits$}", value_db) + format!("{value_db:.digits$}") } }) } @@ -128,7 +128,7 @@ pub fn s2v_f32_panning() -> Arc Option + Send + Sync> { pub fn v2s_f32_hz_then_khz(digits: usize) -> Arc String + Send + Sync> { Arc::new(move |value| { if value < 1000.0 { - format!("{:.digits$} Hz", value) + format!("{value:.digits$} Hz") } else { format!("{:.digits$} kHz", value / 1000.0, digits = digits.max(1)) } @@ -156,7 +156,7 @@ pub fn v2s_f32_hz_then_khz_with_note_name( }; if value < 1000.0 { - format!("{:.digits$} Hz, {}", value, note_str) + format!("{value:.digits$} Hz, {note_str}") } else { format!( "{:.digits$} kHz, {}", diff --git a/src/params/float.rs b/src/params/float.rs index 479361b4..922278f7 100644 --- a/src/params/float.rs +++ b/src/params/float.rs @@ -163,10 +163,10 @@ impl Param for FloatParam { } (None, Some(step_size), false) => { let num_digits = decimals_from_step_size(*step_size); - format!("{:.num_digits$}", value) + format!("{value:.num_digits$}") } (None, None, true) => format!("{}{}", value, self.unit), - (None, None, false) => format!("{}", value), + (None, None, false) => format!("{value}"), } } diff --git a/src/params/integer.rs b/src/params/integer.rs index e8d3d39b..ad5d51e5 100644 --- a/src/params/integer.rs +++ b/src/params/integer.rs @@ -150,7 +150,7 @@ impl Param for IntParam { (Some(f), true) => format!("{}{}", f(value), self.unit), (Some(f), false) => f(value), (None, true) => format!("{}{}", value, self.unit), - (None, false) => format!("{}", value), + (None, false) => format!("{value}"), } } diff --git a/src/wrapper/vst3/param_units.rs b/src/wrapper/vst3/param_units.rs index c2c98a8f..1ded726d 100644 --- a/src/wrapper/vst3/param_units.rs +++ b/src/wrapper/vst3/param_units.rs @@ -55,7 +55,6 @@ impl ParamUnits { // don't contain any parameters and thus aren't present in `groups`. let unique_group_names: HashSet = groups .clone() - .into_iter() .filter_map(|(_, group_name)| { // The root should not be included here since that's a special case in VST3 if !group_name.is_empty() {