diff --git a/serde/src/de/impls.rs b/serde/src/de/impls.rs index b309ccbfb..fd6b22f89 100644 --- a/serde/src/de/impls.rs +++ b/serde/src/de/impls.rs @@ -1825,3 +1825,20 @@ where deserializer.deserialize_enum("Result", VARIANTS, ResultVisitor(PhantomData)) } } + +//////////////////////////////////////////////////////////////////////////////// + +#[cfg(feature = "std")] +use std::num::Wrapping; + +#[cfg(feature = "std")] +impl<'de, T> Deserialize<'de> for Wrapping +where + T: Deserialize<'de> +{ + fn deserialize(deserializer: D) -> Result, D::Error> + where D: Deserializer<'de> + { + Deserialize::deserialize(deserializer).map(Wrapping) + } +} diff --git a/serde/src/ser/impls.rs b/serde/src/ser/impls.rs index 6d6817b7f..a475c33c7 100644 --- a/serde/src/ser/impls.rs +++ b/serde/src/ser/impls.rs @@ -664,3 +664,19 @@ impl Serialize for OsString { self.as_os_str().serialize(serializer) } } + +//////////////////////////////////////////////////////////////////////////////// + +#[cfg(feature = "std")] +use std::num::Wrapping; + +#[cfg(feature = "std")] +impl Serialize for Wrapping { + #[inline] + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + self.0.serialize(serializer) + } +}