mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-23 18:45:06 +08:00
Update milli/src/criterion.rs
Co-authored-by: Clément Renault <clement@meilisearch.com>
This commit is contained in:
parent
f4b8e5675d
commit
0d104a0fce
@ -76,8 +76,8 @@ impl FromStr for Member {
|
|||||||
type Err = UserError;
|
type Err = UserError;
|
||||||
|
|
||||||
fn from_str(text: &str) -> Result<Member, Self::Err> {
|
fn from_str(text: &str) -> Result<Member, Self::Err> {
|
||||||
if let Some(point) = text.strip_prefix("_geoPoint(").and_then(|text| text.strip_suffix(")"))
|
match text.strip_prefix("_geoPoint(").and_then(|text| text.strip_suffix(")")) {
|
||||||
{
|
Some(point) => {
|
||||||
let (lat, long) = point
|
let (lat, long) = point
|
||||||
.split_once(',')
|
.split_once(',')
|
||||||
.ok_or_else(|| UserError::InvalidRankingRuleName { name: text.to_string() })
|
.ok_or_else(|| UserError::InvalidRankingRuleName { name: text.to_string() })
|
||||||
@ -85,16 +85,22 @@ impl FromStr for Member {
|
|||||||
lat.trim()
|
lat.trim()
|
||||||
.parse()
|
.parse()
|
||||||
.and_then(|lat| long.trim().parse().map(|long| (lat, long)))
|
.and_then(|lat| long.trim().parse().map(|long| (lat, long)))
|
||||||
.map_err(|_| UserError::InvalidRankingRuleName { name: text.to_string() })
|
.map_err(|_| UserError::InvalidRankingRuleName {
|
||||||
|
name: text.to_string(),
|
||||||
|
})
|
||||||
})?;
|
})?;
|
||||||
Ok(Member::Geo([lat, long]))
|
Ok(Member::Geo([lat, long]))
|
||||||
} else {
|
}
|
||||||
|
None => {
|
||||||
if is_reserved_keyword(text) {
|
if is_reserved_keyword(text) {
|
||||||
return Err(UserError::InvalidReservedRankingRuleName { name: text.to_string() })?;
|
return Err(UserError::InvalidReservedRankingRuleName {
|
||||||
|
name: text.to_string(),
|
||||||
|
})?;
|
||||||
}
|
}
|
||||||
Ok(Member::Field(text.to_string()))
|
Ok(Member::Field(text.to_string()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for Member {
|
impl fmt::Display for Member {
|
||||||
|
Loading…
Reference in New Issue
Block a user