mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 20:37:15 +02:00
Introduce a rustfmt file
This commit is contained in:
parent
dd57e051d7
commit
3f6bd7fb11
92 changed files with 1251 additions and 2857 deletions
|
@ -25,11 +25,7 @@ const SPLIT_SYMBOL: char = '.';
|
|||
/// ```
|
||||
fn contained_in(selector: &str, key: &str) -> bool {
|
||||
selector.starts_with(key)
|
||||
&& selector[key.len()..]
|
||||
.chars()
|
||||
.next()
|
||||
.map(|c| c == SPLIT_SYMBOL)
|
||||
.unwrap_or(true)
|
||||
&& selector[key.len()..].chars().next().map(|c| c == SPLIT_SYMBOL).unwrap_or(true)
|
||||
}
|
||||
|
||||
/// Map the selected leaf values of a json allowing you to update only the fields that were selected.
|
||||
|
@ -244,10 +240,7 @@ mod tests {
|
|||
fn test_contained_in() {
|
||||
assert!(contained_in("animaux", "animaux"));
|
||||
assert!(contained_in("animaux.chien", "animaux"));
|
||||
assert!(contained_in(
|
||||
"animaux.chien.race.bouvier bernois.fourrure.couleur",
|
||||
"animaux"
|
||||
));
|
||||
assert!(contained_in("animaux.chien.race.bouvier bernois.fourrure.couleur", "animaux"));
|
||||
assert!(contained_in(
|
||||
"animaux.chien.race.bouvier bernois.fourrure.couleur",
|
||||
"animaux.chien"
|
||||
|
@ -726,14 +719,12 @@ mod tests {
|
|||
}
|
||||
});
|
||||
|
||||
map_leaf_values(
|
||||
value.as_object_mut().unwrap(),
|
||||
["jean.race.name"],
|
||||
|key, value| match (value, key) {
|
||||
map_leaf_values(value.as_object_mut().unwrap(), ["jean.race.name"], |key, value| {
|
||||
match (value, key) {
|
||||
(Value::String(name), "jean.race.name") => *name = S("patou"),
|
||||
_ => unreachable!(),
|
||||
},
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
assert_eq!(
|
||||
value,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue