diff --git a/src/param/boolean.rs b/src/param/boolean.rs index 1c9fb096..4ef10976 100644 --- a/src/param/boolean.rs +++ b/src/param/boolean.rs @@ -34,22 +34,6 @@ pub struct BoolParam { string_to_value: Option Option + Send + Sync>>, } -#[allow(clippy::derivable_impls)] -impl Default for BoolParam { - fn default() -> Self { - Self { - value: false, - normalized_value: 0.0, - default: false, - flags: ParamFlags::default(), - value_changed: None, - name: String::new(), - value_to_string: None, - string_to_value: None, - } - } -} - impl Display for BoolParam { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match (self.value, &self.value_to_string) { @@ -165,9 +149,15 @@ impl BoolParam { pub fn new(name: impl Into, default: bool) -> Self { Self { value: default, + normalized_value: if default { 1.0 } else { 0.0 }, default, + + flags: ParamFlags::default(), + value_changed: None, + name: name.into(), - ..Default::default() + value_to_string: None, + string_to_value: None, } } diff --git a/src/param/enums.rs b/src/param/enums.rs index 964e5a4c..80031901 100644 --- a/src/param/enums.rs +++ b/src/param/enums.rs @@ -65,27 +65,6 @@ pub struct EnumParamInner { variants: &'static [&'static str], } -impl Default for EnumParam { - fn default() -> Self { - let variants = T::variants(); - - Self { - inner: EnumParamInner { - inner: IntParam::new( - "", - T::default().to_index() as i32, - IntRange::Linear { - min: 0, - max: variants.len() as i32 - 1, - }, - ), - variants, - }, - _marker: PhantomData, - } - } -} - impl Display for EnumParam { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { self.inner.fmt(f) diff --git a/src/param/float.rs b/src/param/float.rs index 680a60bd..65c29b22 100644 --- a/src/param/float.rs +++ b/src/param/float.rs @@ -65,25 +65,6 @@ pub struct FloatParam { string_to_value: Option Option + Send + Sync>>, } -impl Default for FloatParam { - fn default() -> Self { - Self { - value: 0.0, - normalized_value: 0.0, - default: 0.0, - smoothed: Smoother::none(), - flags: ParamFlags::default(), - value_changed: None, - range: FloatRange::default(), - step_size: None, - name: String::new(), - unit: "", - value_to_string: None, - string_to_value: None, - } - } -} - impl Display for FloatParam { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match (&self.value_to_string, &self.step_size) { @@ -235,9 +216,17 @@ impl FloatParam { value: default, normalized_value: range.normalize(default), default, + smoothed: Smoother::none(), + + flags: ParamFlags::default(), + value_changed: None, + range, + step_size: None, name: name.into(), - ..Default::default() + unit: "", + value_to_string: None, + string_to_value: None, } } diff --git a/src/param/integer.rs b/src/param/integer.rs index 2d73382f..e244324c 100644 --- a/src/param/integer.rs +++ b/src/param/integer.rs @@ -61,24 +61,6 @@ pub struct IntParam { string_to_value: Option Option + Send + Sync>>, } -impl Default for IntParam { - fn default() -> Self { - Self { - value: 0, - normalized_value: 0.0, - default: 0, - smoothed: Smoother::none(), - flags: ParamFlags::default(), - value_changed: None, - range: IntRange::default(), - name: String::new(), - unit: "", - value_to_string: None, - string_to_value: None, - } - } -} - impl Display for IntParam { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match &self.value_to_string { @@ -199,9 +181,16 @@ impl IntParam { value: default, normalized_value: range.normalize(default), default, + smoothed: Smoother::none(), + + flags: ParamFlags::default(), + value_changed: None, + range, name: name.into(), - ..Default::default() + unit: "", + value_to_string: None, + string_to_value: None, } }