Skip to content

Commit

Permalink
Remove Serializer from name of private type that is not a Serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Aug 2, 2023
1 parent 110bf10 commit 5cdd82d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions serde/src/private/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1356,23 +1356,23 @@ where
}
}

pub struct AdjacentlyTaggedEnumVariantSerializer {
pub struct AdjacentlyTaggedEnumVariant {
tag: &'static str,
variant_index: u32,
variant_name: &'static str,
}

impl AdjacentlyTaggedEnumVariantSerializer {
impl AdjacentlyTaggedEnumVariant {
pub fn new(tag: &'static str, variant_index: u32, variant_name: &'static str) -> Self {
AdjacentlyTaggedEnumVariantSerializer {
AdjacentlyTaggedEnumVariant {
tag,
variant_index,
variant_name,
}
}
}

impl Serialize for AdjacentlyTaggedEnumVariantSerializer {
impl Serialize for AdjacentlyTaggedEnumVariant {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
Expand Down
8 changes: 4 additions & 4 deletions serde_derive/src/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ fn serialize_adjacently_tagged_variant(
let this_type = &params.this_type;
let type_name = cattrs.name().serialize_name();
let variant_name = variant.attrs.name().serialize_name();
let variant_serializer = quote!(&_serde::__private::ser::AdjacentlyTaggedEnumVariantSerializer::new(#tag, #variant_index, #variant_name));
let variant = quote!(&_serde::__private::ser::AdjacentlyTaggedEnumVariant::new(#tag, #variant_index, #variant_name));

let inner = Stmts(if let Some(path) = variant.attrs.serialize_with() {
let ser = wrap_serialize_variant_with(params, path, variant);
Expand All @@ -662,7 +662,7 @@ fn serialize_adjacently_tagged_variant(
let mut __struct = _serde::Serializer::serialize_struct(
__serializer, #type_name, 1)?;
_serde::ser::SerializeStruct::serialize_field(
&mut __struct, #tag, #variant_serializer)?;
&mut __struct, #tag, #variant)?;
_serde::ser::SerializeStruct::end(__struct)
};
}
Expand All @@ -679,7 +679,7 @@ fn serialize_adjacently_tagged_variant(
let mut __struct = _serde::Serializer::serialize_struct(
__serializer, #type_name, 2)?;
_serde::ser::SerializeStruct::serialize_field(
&mut __struct, #tag, #variant_serializer)?;
&mut __struct, #tag, #variant)?;
#func(
&mut __struct, #content, #field_expr)?;
_serde::ser::SerializeStruct::end(__struct)
Expand Down Expand Up @@ -744,7 +744,7 @@ fn serialize_adjacently_tagged_variant(
let mut __struct = _serde::Serializer::serialize_struct(
__serializer, #type_name, 2)?;
_serde::ser::SerializeStruct::serialize_field(
&mut __struct, #tag, #variant_serializer)?;
&mut __struct, #tag, #variant)?;
_serde::ser::SerializeStruct::serialize_field(
&mut __struct, #content, &__AdjacentlyTagged {
data: (#(#fields_ident,)*),
Expand Down

0 comments on commit 5cdd82d

Please sign in to comment.