Sha256: fa499e7e94c869dcb6f77d0dcb7b6ea5e8dd1f81ae0026758c4fc16b350a783e
Contents?: true
Size: 947 Bytes
Versions: 36
Compression:
Stored size: 947 Bytes
Contents
//! Serde `Serialize` and `Deserialize` implementations for `MaybeOwned`. use serde::{Deserialize, Deserializer, Serialize, Serializer}; use {MaybeOwned, MaybeOwnedMut}; macro_rules! serde_impls { ($Name:ident) => { impl<'a, T: Serialize> Serialize for $Name<'a, T> { fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> { match self { Self::Owned(v) => v.serialize(serializer), Self::Borrowed(v) => v.serialize(serializer), } } } impl<'a, 'de, T: Deserialize<'de>> Deserialize<'de> for $Name<'a, T> { fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: Deserializer<'de>, { T::deserialize(deserializer).map(Self::Owned) } } }; } serde_impls!(MaybeOwned); serde_impls!(MaybeOwnedMut);
Version data entries
36 entries across 36 versions & 1 rubygems