apply clippy suggestions

This commit is contained in:
Tamo 2022-01-10 15:59:04 +01:00
parent 0fcde35a20
commit 92804f6f45
No known key found for this signature in database
GPG Key ID: 20CD8020AFA88D69
4 changed files with 5 additions and 11 deletions

View File

@ -63,11 +63,5 @@ pub fn parse_to(input: Span) -> IResult<FilterCondition> {
let (input, (key, from, _, to)) = let (input, (key, from, _, to)) =
tuple((parse_value, parse_value, tag("TO"), cut(parse_value)))(input)?; tuple((parse_value, parse_value, tag("TO"), cut(parse_value)))(input)?;
Ok(( Ok((input, FilterCondition::Condition { fid: key, op: Between { from, to } }))
input,
FilterCondition::Condition {
fid: key.into(),
op: Between { from: from.into(), to: to.into() },
},
))
} }

View File

@ -19,14 +19,14 @@ impl<E> NomErrorExt<E> for nom::Err<E> {
fn map_err<O: FnOnce(E) -> E>(self, op: O) -> nom::Err<E> { fn map_err<O: FnOnce(E) -> E>(self, op: O) -> nom::Err<E> {
match self { match self {
e @ Self::Failure(_) => e, e @ Self::Failure(_) => e,
e => e.map(|e| op(e)), e => e.map(op),
} }
} }
fn map_fail<O: FnOnce(E) -> E>(self, op: O) -> nom::Err<E> { fn map_fail<O: FnOnce(E) -> E>(self, op: O) -> nom::Err<E> {
match self { match self {
e @ Self::Error(_) => e, e @ Self::Error(_) => e,
e => e.map(|e| op(e)), e => e.map(op),
} }
} }
} }

View File

@ -233,7 +233,7 @@ fn parse_geo_point(input: Span) -> IResult<FilterCondition> {
multispace0, multispace0,
tag("_geoPoint"), tag("_geoPoint"),
// if we were able to parse `_geoPoint` we are going to return a Failure whatever happens next. // if we were able to parse `_geoPoint` we are going to return a Failure whatever happens next.
cut(delimited(char('('), separated_list1(tag(","), ws(|c| recognize_float(c))), char(')'))), cut(delimited(char('('), separated_list1(tag(","), ws(recognize_float)), char(')'))),
))(input) ))(input)
.map_err(|e| e.map(|_| Error::new_from_kind(input, ErrorKind::ReservedGeo("_geoPoint"))))?; .map_err(|e| e.map(|_| Error::new_from_kind(input, ErrorKind::ReservedGeo("_geoPoint"))))?;
// if we succeeded we still return a `Failure` because geoPoints are not allowed // if we succeeded we still return a `Failure` because geoPoints are not allowed

View File

@ -10,7 +10,7 @@ fn main() {
} }
Err(e) => { Err(e) => {
println!("❎ Invalid filter"); println!("❎ Invalid filter");
println!("{}", e.to_string()); println!("{}", e);
} }
} }
} }