mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-27 07:14:26 +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 operator = alt((tag("<="), tag(">="), tag("!="), tag("<"), tag(">"), tag("=")));
|
||||||
let (input, (fid, op, value)) = tuple((parse_value, operator, cut(parse_value)))(input)?;
|
let (input, (fid, op, value)) = tuple((parse_value, operator, cut(parse_value)))(input)?;
|
||||||
|
|
||||||
|
let condition = match *op.fragment() {
|
||||||
match *op.fragment() {
|
"=" => FilterCondition::Condition { fid, op: Equal(value) },
|
||||||
"=" => {
|
"!=" => FilterCondition::Condition { fid, op: NotEqual(value) },
|
||||||
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: GreaterThan(value) },
|
||||||
"<" => FilterCondition::Condition { fid, op: LowerThan(value) },
|
"<" => FilterCondition::Condition { fid, op: LowerThan(value) },
|
||||||
"<=" => FilterCondition::Condition { fid, op: LowerThanOrEqual(value) },
|
"<=" => FilterCondition::Condition { fid, op: LowerThanOrEqual(value) },
|
||||||
">=" => FilterCondition::Condition { fid, op: GreaterThanOrEqual(value) },
|
">=" => FilterCondition::Condition { fid, op: GreaterThanOrEqual(value) },
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
Ok((input, k))
|
|
||||||
}
|
Ok((input, condition))
|
||||||
_ => unreachable!(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// to = value value TO value
|
/// to = value value TO value
|
||||||
|
Loading…
Reference in New Issue
Block a user