mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-01-31 15:31:53 +08:00
feat: Add Config.update_with(_) method to merge 2 config
This commit is contained in:
parent
55823c5d5d
commit
1941cb16c0
@ -25,7 +25,6 @@ pub struct Config {
|
|||||||
pub access_token: Option<AccessToken>,
|
pub access_token: Option<AccessToken>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
pub(crate) fn default() -> Config {
|
pub(crate) fn default() -> Config {
|
||||||
Config {
|
Config {
|
||||||
@ -36,4 +35,22 @@ impl Config {
|
|||||||
access_token: None,
|
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);
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user