feat: Add Config.update_with(_) method to merge 2 config

This commit is contained in:
Quentin de Quelen 2019-02-20 11:04:22 +01:00
parent 55823c5d5d
commit 1941cb16c0

View File

@ -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);
};
}
}