Skip to content

Commit 25a1701

Browse files
committed
Add PartialEq
1 parent b34e182 commit 25a1701

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/parser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5526,7 +5526,7 @@ impl<'a> Parser<'a> {
55265526
}
55275527

55285528
pub fn parse_function_args(&mut self) -> Result<FunctionArg, ParserError> {
5529-
if self.peek_nth_token(1).token == Token::RArrow {
5529+
if self.peek_nth_token(1) == Token::RArrow {
55305530
let name = self.parse_identifier()?;
55315531

55325532
self.expect_token(&Token::RArrow)?;

src/tokenizer.rs

+12-3
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,12 @@ impl TokenWithLocation {
329329
}
330330
}
331331

332+
impl PartialEq<Token> for TokenWithLocation {
333+
fn eq(&self, other: &Token) -> bool {
334+
&self.token == other
335+
}
336+
}
337+
332338
impl fmt::Display for TokenWithLocation {
333339
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
334340
self.token.fmt(f)
@@ -474,7 +480,8 @@ impl<'a> Tokenizer<'a> {
474480
chars.next(); // consume, to check the next char
475481
match chars.peek() {
476482
Some('\'') => {
477-
let s = self.tokenize_escaped_single_quoted_string(starting_loc, chars)?;
483+
let s =
484+
self.tokenize_escaped_single_quoted_string(starting_loc, chars)?;
478485
Ok(Some(Token::EscapedStringLiteral(s)))
479486
}
480487
_ => {
@@ -933,8 +940,10 @@ impl<'a> Tokenizer<'a> {
933940
last_ch = ch;
934941
}
935942
None => {
936-
break self
937-
.tokenizer_error(chars.location(), "Unexpected EOF while in a multi-line comment")
943+
break self.tokenizer_error(
944+
chars.location(),
945+
"Unexpected EOF while in a multi-line comment",
946+
)
938947
}
939948
}
940949
}

0 commit comments

Comments
 (0)