feat: Add Config.update_with(_) method to merge 2 config
@@ -25,7 +25,6 @@ pub struct Config {
pub access_token: Option<AccessToken>,
}
-
impl Config {
pub(crate) fn default() -> Config {
Config {
@@ -36,4 +35,22 @@ impl Config {
access_token: None,
}
}
+
+ pub fn update_with(&mut self, new: Config) {
+ if let Some(stop_words) = new.stop_words {
+ self.stop_words = Some(stop_words);
+ };
+ if let Some(ranking_order) = new.ranking_order {
+ self.ranking_order = Some(ranking_order);
+ };
+ if let Some(distinct_field) = new.distinct_field {
+ self.distinct_field = Some(distinct_field);
+ };
+ if let Some(ranking_rules) = new.ranking_rules {
+ self.ranking_rules = Some(ranking_rules);
+ };
+ if let Some(access_token) = new.access_token {
+ self.access_token = Some(access_token);
+ };
+ }
}
