Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Serialize of adjacently tagged newtype variants #1227

Merged
merged 1 commit into from
Apr 21, 2018
Merged

Commits on Apr 21, 2018

  1. Improve Serialize of adjacently tagged newtype variants

    The existing implementation was unnecessarily complicated.
    
        struct __AdjacentlyTagged<'__a> {
            data: (&'__a String,),
            phantom: _serde::export::PhantomData<AdjacentlyTagged>,
        }
        impl<'__a> _serde::Serialize for __AdjacentlyTagged<'__a> {
            fn serialize<__S>(
                &self,
                __serializer: __S,
            ) -> _serde::export::Result<__S::Ok, __S::Error>
            where
                __S: _serde::Serializer,
            {
                let (__field0,) = self.data;
                _serde::Serialize::serialize(__field0, __serializer)
            }
        }
        _serde::ser::SerializeStruct::serialize_field(
            &mut __struct,
            "content",
            &__AdjacentlyTagged {
                data: (__field0,),
                phantom: _serde::export::PhantomData::<AdjacentlyTagged>,
            },
        )?;
    
    Instead the new implementation does simply:
    
        _serde::ser::SerializeStruct::serialize_field(
            &mut __struct,
            "content",
            __field0,
        )?;
    dtolnay committed Apr 21, 2018
    Configuration menu
    Copy the full SHA
    6d1807b View commit details
    Browse the repository at this point in the history