From e27b850b0989609e7e97af8023e915168db57a55 Mon Sep 17 00:00:00 2001 From: ManyTheFish Date: Mon, 8 Jan 2024 14:03:47 +0100 Subject: [PATCH] move the default display strategy on setting getter function --- meilisearch-types/src/settings.rs | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/meilisearch-types/src/settings.rs b/meilisearch-types/src/settings.rs index 7606fa44a..9613cb9f3 100644 --- a/meilisearch-types/src/settings.rs +++ b/meilisearch-types/src/settings.rs @@ -37,17 +37,6 @@ where .serialize(s) } -fn serialize_with_default(field: &Setting, s: S) -> std::result::Result -where - T: Default + Serialize, - S: Serializer, -{ - match field { - Setting::Set(value) => value.serialize(s), - Setting::Reset | Setting::NotSet => T::default().serialize(s), - } -} - #[derive(Clone, Default, Debug, Serialize, PartialEq, Eq)] pub struct Checked; @@ -197,11 +186,7 @@ pub struct Settings { #[serde(default, skip_serializing_if = "Setting::is_not_set")] #[deserr(default, error = DeserrJsonError)] pub distinct_attribute: Setting, - #[serde( - default, - serialize_with = "serialize_with_default", - skip_serializing_if = "Setting::is_not_set" - )] + #[serde(default, skip_serializing_if = "Setting::is_not_set")] #[deserr(default, error = DeserrJsonError)] pub proximity_precision: Setting, #[serde(default, skip_serializing_if = "Setting::is_not_set")] @@ -641,10 +626,7 @@ pub fn settings( Some(field) => Setting::Set(field), None => Setting::Reset, }, - proximity_precision: match proximity_precision { - Some(precision) => Setting::Set(precision), - None => Setting::Reset, - }, + proximity_precision: Setting::Set(proximity_precision.unwrap_or_default()), synonyms: Setting::Set(synonyms), typo_tolerance: Setting::Set(typo_tolerance), faceting: Setting::Set(faceting),