Skip to content

Commit 72c0a06

Browse files
authored
Merge pull request RustPython#4404 from harupy/merge-match-arms
Merge match arms in `StringParser.parse_formatted_value`
2 parents 6480619 + 4e681b5 commit 72c0a06

File tree

1 file changed

+3
-18
lines changed

1 file changed

+3
-18
lines changed

compiler/parser/src/string_parser.rs

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -189,26 +189,11 @@ impl<'a> StringParser<'a> {
189189
match ch {
190190
// can be integrated better with the remaining code, but as a starting point ok
191191
// in general I would do here a tokenizing of the fstrings to omit this peeking.
192-
'!' if self.peek() == Some(&'=') => {
193-
expression.push_str("!=");
194-
self.next_char();
195-
}
196-
197-
'=' if self.peek() == Some(&'=') => {
198-
expression.push_str("==");
199-
self.next_char();
200-
}
201-
202-
'>' if self.peek() == Some(&'=') => {
203-
expression.push_str(">=");
204-
self.next_char();
205-
}
206-
207-
'<' if self.peek() == Some(&'=') => {
208-
expression.push_str("<=");
192+
'!' | '=' | '>' | '<' if self.peek() == Some(&'=') => {
193+
expression.push(ch);
194+
expression.push('=');
209195
self.next_char();
210196
}
211-
212197
'!' if delims.is_empty() && self.peek() != Some(&'=') => {
213198
if expression.trim().is_empty() {
214199
return Err(EmptyExpression.to_lexical_error(self.get_pos()));

0 commit comments

Comments
 (0)