From 2b45ef22a5b536fcf6d8814a88a69b2ce7fce342 Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Sun, 17 Jan 2021 21:56:25 +0100 Subject: [PATCH] Use explicit unreachable in rust pattern matching --- rslib/src/search/parser.rs | 5 ++++- rslib/src/search/sqlwriter.rs | 15 +++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/rslib/src/search/parser.rs b/rslib/src/search/parser.rs index a491a4694..e547f319b 100644 --- a/rslib/src/search/parser.rs +++ b/rslib/src/search/parser.rs @@ -461,7 +461,10 @@ fn parse_prop(s: &str) -> ParseResult { )); }; - Ok(SearchNode::Property { operator, kind }) + Ok(SearchNode::Property { + operator: operator.to_string(), + kind, + }) } /// eg added:1 diff --git a/rslib/src/search/sqlwriter.rs b/rslib/src/search/sqlwriter.rs index 7a359333a..e64b7f6df 100644 --- a/rslib/src/search/sqlwriter.rs +++ b/rslib/src/search/sqlwriter.rs @@ -226,8 +226,19 @@ impl SqlWriter<'_> { ">=" => write!(self.sql, " >= {}", day_before_cutoff_ms), "<" => write!(self.sql, " < {}", day_before_cutoff_ms), "<=" => write!(self.sql, " < {}", target_cutoff_ms), - "=" => write!(self.sql, " between {} and {}", day_before_cutoff_ms, target_cutoff_ms - 1), - _ /* "!=" */ => write!(self.sql, " not between {} and {}", day_before_cutoff_ms, target_cutoff_ms - 1), + "=" => write!( + self.sql, + " between {} and {}", + day_before_cutoff_ms, + target_cutoff_ms - 1 + ), + "!=" => write!( + self.sql, + " not between {} and {}", + day_before_cutoff_ms, + target_cutoff_ms - 1 + ), + _ => unreachable!("unexpected op"), } .unwrap();