Merge match arms in parse_formatted_value

This commit is contained in:
harupy 2023-01-02 23:16:51 +09:00
parent bf715ab1ca
commit 83ebf39ecc

View file

@ -189,26 +189,11 @@ impl<'a> StringParser<'a> {
match ch { match ch {
// can be integrated better with the remaining code, but as a starting point ok // can be integrated better with the remaining code, but as a starting point ok
// in general I would do here a tokenizing of the fstrings to omit this peeking. // in general I would do here a tokenizing of the fstrings to omit this peeking.
'!' if self.peek() == Some(&'=') => { '!' | '=' | '>' | '<' if self.peek() == Some(&'=') => {
expression.push_str("!="); expression.push(ch);
expression.push('=');
self.next_char(); self.next_char();
} }
'=' if self.peek() == Some(&'=') => {
expression.push_str("==");
self.next_char();
}
'>' if self.peek() == Some(&'=') => {
expression.push_str(">=");
self.next_char();
}
'<' if self.peek() == Some(&'=') => {
expression.push_str("<=");
self.next_char();
}
'!' if delims.is_empty() && self.peek() != Some(&'=') => { '!' if delims.is_empty() && self.peek() != Some(&'=') => {
if expression.trim().is_empty() { if expression.trim().is_empty() {
return Err(EmptyExpression.to_lexical_error(self.get_pos())); return Err(EmptyExpression.to_lexical_error(self.get_pos()));