From 27102df4768b8d36d5ec8fd1617cfa083176ed42 Mon Sep 17 00:00:00 2001 From: overlookmotel Date: Sun, 21 Apr 2024 06:04:51 +0100 Subject: [PATCH] refactor(napi): remove unnecessary custom `Serialize` impl for `Atom` (#3041) Custom `Serialize` impl on `Atom` is not required - can just use serde derive. --- crates/oxc_span/src/atom.rs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/crates/oxc_span/src/atom.rs b/crates/oxc_span/src/atom.rs index e8b5cc20d..9c28b5cfc 100644 --- a/crates/oxc_span/src/atom.rs +++ b/crates/oxc_span/src/atom.rs @@ -20,18 +20,10 @@ pub const MAX_INLINE_LEN: usize = 16; /// Use [CompactStr] with [Atom::to_compact_str] or [Atom::into_compact_str] for the /// lifetimeless form. #[derive(Clone, Eq)] +#[cfg_attr(feature = "serialize", derive(Serialize))] +#[cfg_attr(feature = "serialize", serde(transparent))] pub struct Atom<'a>(&'a str); -#[cfg(feature = "serialize")] -impl<'a> Serialize for Atom<'a> { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - serializer.serialize_str(self.as_str()) - } -} - impl<'a> Atom<'a> { #[inline] pub fn as_str(&self) -> &str {