mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-23 13:24:27 +01:00
flatten a match
This commit is contained in:
parent
15bd14297e
commit
ef0d5a8240
@ -45,28 +45,17 @@ pub fn parse_condition(input: Span) -> IResult<FilterCondition> {
|
||||
let operator = alt((tag("<="), tag(">="), tag("!="), tag("<"), tag(">"), tag("=")));
|
||||
let (input, (fid, op, value)) = tuple((parse_value, operator, cut(parse_value)))(input)?;
|
||||
|
||||
|
||||
match *op.fragment() {
|
||||
"=" => {
|
||||
let k = FilterCondition::Condition { fid, op: Equal(value) };
|
||||
Ok((input, k))
|
||||
}
|
||||
"!=" => {
|
||||
let k = FilterCondition::Condition { fid, op: NotEqual(value) };
|
||||
Ok((input, k))
|
||||
}
|
||||
">" | "<" | "<=" | ">=" => {
|
||||
let k = match *op.fragment() {
|
||||
">" => FilterCondition::Condition { fid, op: GreaterThan(value) },
|
||||
"<" => FilterCondition::Condition { fid, op: LowerThan(value) },
|
||||
"<=" => FilterCondition::Condition { fid, op: LowerThanOrEqual(value) },
|
||||
">=" => FilterCondition::Condition { fid, op: GreaterThanOrEqual(value) },
|
||||
_ => unreachable!(),
|
||||
};
|
||||
Ok((input, k))
|
||||
}
|
||||
let condition = match *op.fragment() {
|
||||
"=" => FilterCondition::Condition { fid, op: Equal(value) },
|
||||
"!=" => FilterCondition::Condition { fid, op: NotEqual(value) },
|
||||
">" => FilterCondition::Condition { fid, op: GreaterThan(value) },
|
||||
"<" => FilterCondition::Condition { fid, op: LowerThan(value) },
|
||||
"<=" => FilterCondition::Condition { fid, op: LowerThanOrEqual(value) },
|
||||
">=" => FilterCondition::Condition { fid, op: GreaterThanOrEqual(value) },
|
||||
_ => unreachable!(),
|
||||
}
|
||||
};
|
||||
|
||||
Ok((input, condition))
|
||||
}
|
||||
|
||||
/// to = value value TO value
|
||||
|
Loading…
Reference in New Issue
Block a user