You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// This should serialize and deserialize directly as String, rather than as newtype.#[derive(Serialize,Deserialize)]#[serde(transparent)]structTransparent(String);// Generated code.implSerializeforTransparent{fnserialize<S>(&self,serializer:S) -> Result<S::Ok,S::Error>whereS:Serializer{self.0.serialize(serializer)}}impl<'de>Deserialize<'de>forTransparent{fndeserialize<D>(deserializer:D) -> Result<Self,D::Error>whereD:Deserializer<'de>{Deserialize::deserialize(deserializer).map(Transparent)}}
Should also work for structs with one field, and structs and tuple structs with all but one skipped field.
By analogy with
#[repr(transparent)]
.Should also work for structs with one field, and structs and tuple structs with all but one skipped field.
@bluss
The text was updated successfully, but these errors were encountered: