Use explicit unreachable in rust pattern matching

This commit is contained in:
Henrik Giesel 2021-01-17 21:56:25 +01:00
parent bc81165be4
commit 2b45ef22a5
2 changed files with 17 additions and 3 deletions

View File

@ -461,7 +461,10 @@ fn parse_prop(s: &str) -> ParseResult<SearchNode> {
)); ));
}; };
Ok(SearchNode::Property { operator, kind }) Ok(SearchNode::Property {
operator: operator.to_string(),
kind,
})
} }
/// eg added:1 /// eg added:1

View File

@ -226,8 +226,19 @@ impl SqlWriter<'_> {
">=" => write!(self.sql, " >= {}", day_before_cutoff_ms), ">=" => write!(self.sql, " >= {}", day_before_cutoff_ms),
"<" => write!(self.sql, " < {}", day_before_cutoff_ms), "<" => write!(self.sql, " < {}", day_before_cutoff_ms),
"<=" => write!(self.sql, " < {}", target_cutoff_ms), "<=" => write!(self.sql, " < {}", target_cutoff_ms),
"=" => write!(self.sql, " between {} and {}", day_before_cutoff_ms, target_cutoff_ms - 1), "=" => write!(
_ /* "!=" */ => write!(self.sql, " not between {} and {}", day_before_cutoff_ms, target_cutoff_ms - 1), 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(); .unwrap();