feat(span): impl<'a> PartialEq<str> for Atom<'a> (#2649)

This commit is contained in:
Boshen 2024-03-09 17:30:14 +08:00 committed by GitHub
parent c72675e89e
commit 8b3de7748b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

View file

@ -244,7 +244,7 @@ fn check_expression(expr: &Expression, ctx: &LintContext<'_>) -> Option<oxc_span
}
}
Expression::TemplateLiteral(lit) => {
lit.quasi().and_then(|quasi| if quasi == &"then" { Some(lit.span) } else { None })
lit.quasi().and_then(|quasi| if quasi == "then" { Some(lit.span) } else { None })
}
Expression::Identifier(ident) => {
let tab = ctx.semantic().symbols();

View file

@ -92,6 +92,12 @@ impl<'a> PartialEq<Atom<'a>> for &str {
}
}
impl<'a> PartialEq<str> for Atom<'a> {
fn eq(&self, other: &str) -> bool {
self.as_str() == other
}
}
impl<'a> hash::Hash for Atom<'a> {
fn hash<H: hash::Hasher>(&self, hasher: &mut H) {
self.as_str().hash(hasher);