From 8b3de7748bf0e66339b7a4c8c25e2ec8b05b3a45 Mon Sep 17 00:00:00 2001 From: Boshen Date: Sat, 9 Mar 2024 17:30:14 +0800 Subject: [PATCH] feat(span): `impl<'a> PartialEq for Atom<'a>` (#2649) --- crates/oxc_linter/src/rules/unicorn/no_thenable.rs | 2 +- crates/oxc_span/src/atom.rs | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/oxc_linter/src/rules/unicorn/no_thenable.rs b/crates/oxc_linter/src/rules/unicorn/no_thenable.rs index 77d672978..9b80c6f9f 100644 --- a/crates/oxc_linter/src/rules/unicorn/no_thenable.rs +++ b/crates/oxc_linter/src/rules/unicorn/no_thenable.rs @@ -244,7 +244,7 @@ fn check_expression(expr: &Expression, ctx: &LintContext<'_>) -> Option { - 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(); diff --git a/crates/oxc_span/src/atom.rs b/crates/oxc_span/src/atom.rs index c7f47fece..5dabea103 100644 --- a/crates/oxc_span/src/atom.rs +++ b/crates/oxc_span/src/atom.rs @@ -92,6 +92,12 @@ impl<'a> PartialEq> for &str { } } +impl<'a> PartialEq for Atom<'a> { + fn eq(&self, other: &str) -> bool { + self.as_str() == other + } +} + impl<'a> hash::Hash for Atom<'a> { fn hash(&self, hasher: &mut H) { self.as_str().hash(hasher);