From 83ebf39ecc0a369a3394f6d07bdd69e9bac0dfa2 Mon Sep 17 00:00:00 2001 From: harupy Date: Mon, 2 Jan 2023 23:16:51 +0900 Subject: [PATCH] Merge match arms in parse_formatted_value --- parser/src/string_parser.rs | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/parser/src/string_parser.rs b/parser/src/string_parser.rs index 1889b3f..8761a35 100644 --- a/parser/src/string_parser.rs +++ b/parser/src/string_parser.rs @@ -189,26 +189,11 @@ impl<'a> StringParser<'a> { match ch { // 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. - '!' if self.peek() == Some(&'=') => { - expression.push_str("!="); + '!' | '=' | '>' | '<' if self.peek() == Some(&'=') => { + expression.push(ch); + expression.push('='); 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 expression.trim().is_empty() { return Err(EmptyExpression.to_lexical_error(self.get_pos()));