Remix.run Logo
dhosek 14 hours ago

The gotcha is what happens when TypeWithSomeSerialization is not something you’re using directly but is contained within SomeOtherTypeWithSomeSerialization which you are using directly. Then things get messy.

deathanatos 9 hours ago | parent | next [-]

We can't say with certainty how an unspecified in-the-future library might work, so I'm going to use serde as a stand-in.

You can implement `Serialize` for a wrapper type and still serialize `SomeOtherTypeWithSomeSerialization` (which might be used by the type being wrapper directly or indirectly) differently. It might not be derivable, of course, but "I don't want the default" sort of makes that a given.

bigfishrunning 11 hours ago | parent | prev [-]

In that case, wrap a reference maybe?

    pub struct TypeWithDifferentSerialization(&TypeWithSomeSerialization)